123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- package fms
- import (
- "hongze/fms_api/global"
- "time"
- )
- // ContractServiceTemplate 合同服务模板表
- type ContractServiceTemplate struct {
- ServiceTemplateId int `gorm:"primaryKey;column:service_template_id" json:"service_template_id"`
- ProductId int `gorm:"column:product_id" json:"product_id" description:"产品id"`
- Pid int `gorm:"column:pid" json:"pid" description:"父级id"`
- Title string `gorm:"column:title" json:"title" description:"套餐名称"`
- Value string `gorm:"column:value" json:"value" description:"对应的数据"`
- SelectType string `gorm:"column:select_type" json:"select_type" description:"选择器类型,单选还是多选,radio;单选:checkbox"`
- SelectName string `gorm:"column:select_name" json:"select_name" description:"选择器名称"`
- TableValue string `gorm:"column:table_value" json:"table_value" description:"表格数据,用于word生成时的json数据"`
- Remark string `gorm:"column:remark" json:"remark" description:"表头备注"`
- ChartPermissionId int `gorm:"column:chart_permission_id" json:"chart_permission_id" description:"权限id"`
- CreateTime time.Time `gorm:"column:create_time" json:"create_time" description:"创建时间"`
- ModifyTime time.Time `gorm:"column:modify_time" json:"modify_time" description:"修改时间"`
- IsDelete int `gorm:"column:is_delete" json:"-" description:"删除状态: 0-正常; 1-删除"`
- }
- func (st *ContractServiceTemplate) TableName() string {
- return "contract_service_template"
- }
- func (st *ContractServiceTemplate) List(condition string, pars []interface{}) (list []*ContractServiceTemplate, err error) {
- list = make([]*ContractServiceTemplate, 0)
- err = global.DEFAULT_MYSQL.Model(st).
- Where("is_delete = 0").
- Where(condition, pars...).
- Find(&list).Error
- return
- }
- func (st *ContractServiceTemplate) OrderList(condition string, pars []interface{}) (list []*ContractServiceTemplate, err error) {
- list = make([]*ContractServiceTemplate, 0)
- err = global.DEFAULT_MYSQL.Model(st).
- Where("is_delete = 0").
- Where(condition, pars...).
- Order("sort ASC ").
- Find(&list).Error
- return
- }
- type ContractServiceTemplateItem struct {
- ServiceTemplateId int `json:"service_template_id" description:"套餐模板ID"`
- ProductId int `json:"product_id" description:"产品ID"`
- Pid int `json:"pid" description:"父级ID"`
- ParentTitle string `json:"parent_title" description:"父级套餐名称"`
- Title string `json:"title" description:"套餐名称"`
- Value string `json:"value" description:"对应的数据"`
- SelectType string `json:"select_type" description:"选择器类型:radio-单选; checkbox-多选"`
- SelectName string `json:"select_name" description:"选择器名称"`
- ChartPermissionId int `json:"chart_permission_id" description:"权限ID"`
- }
- type ContractServiceTemplateList struct {
- Title string `json:"title"`
- Children []*ContractServiceTemplateMapItems `json:"children"`
- }
- type ContractServiceTemplateMapItems struct {
- ContractServiceTemplateItem
- Children []*ContractServiceTemplateMapItems `json:"children"`
- Detail []*ContractServiceDetail `json:"detail"`
- }
- type ContractServiceTemplateMapItems2 struct {
- ServiceTemplateId int `json:"service_template_id" description:"套餐模板ID"`
- ProductId int `json:"product_id" description:"产品id"`
- Pid int `json:"pid" description:"父级id"`
- Title string `json:"title" description:"套餐名称"`
- Value string `json:"value" description:"对应的数据"`
- SelectType string `json:"select_type" description:"选择器类型,单选还是多选,radio;单选:checkbox"`
- SelectName string `json:"select_name" description:"选择器名称"`
- ChartPermissionId int `json:"chart_permission_id" description:"权限id"`
- Children []*ContractServiceTemplateMapItems `json:"children"`
- Detail []*ContractServiceDetail `json:"detail"`
- }
- // ContractServiceListReq CRM系统合同套餐-列表请求体
- type ContractServiceListReq struct {
- ProductId string `json:"product_id" form:"product_id" description:"产品:空值-全部; 1-FICC; 2-权益"`
- }
- func GetContractServiceTemplateMapByProductId(productId int) (items []*ContractServiceTemplateItem, err error) {
- items = make([]*ContractServiceTemplateItem, 0)
- err = global.DEFAULT_MYSQL.Table("contract_service_template").
- Where("product_id = ? AND pid = 0 AND is_delete = 0", productId).
- Order("sort ASC").
- Find(&items).Error
- return
- }
- func GetContractServiceTemplateAllByProductId(productId int) (items []*ContractServiceTemplateItem, err error) {
- items = make([]*ContractServiceTemplateItem, 0)
- err = global.DEFAULT_MYSQL.Table("contract_service_template").
- Where("product_id = ? AND is_delete = 0", productId).
- Order("sort ASC").
- Find(&items).Error
- return
- }
- func GetContractServiceTemplateMapByParentId(parentId int) (items []*ContractServiceTemplateItem, err error) {
- items = make([]*ContractServiceTemplateItem, 0)
- err = global.DEFAULT_MYSQL.Table("contract_service_template").
- Where("pid = ? AND is_delete = 0", parentId).
- Find(&items).Error
- return
- }
- // GetContractServiceTemplateById 主键获取合同套餐模板
- func GetContractServiceTemplateById(templateId int) (item *ContractServiceTemplate, err error) {
- err = global.DEFAULT_MYSQL.Model(ContractServiceTemplate{}).
- Where("service_template_id = ? AND is_delete = 0", templateId).
- First(&item).Error
- return
- }
- func GetContractServiceTemplateSecond() (items []*ContractServiceTemplateItem, err error) {
- items = make([]*ContractServiceTemplateItem, 0)
- err = global.DEFAULT_MYSQL.Table("contract_service_template").
- Where("pid = 0 AND is_delete = 0").
- Order("sort ASC").
- Find(&items).Error
- return
- }
- type ContractServiceTemplateFullName struct {
- ContractServiceTemplateItem
- ParentTitle string
- }
- type ContractServiceTemplateFormat struct {
- FormatTitle string
- ServiceTemplateId int
- ServiceTemplatePid int
- ServiceProductId int
- }
- type ContractServiceTemplateFormatList []ContractServiceTemplateFormat
- func (c ContractServiceTemplateFormatList) Len() int {
- return len(c)
- }
- func (c ContractServiceTemplateFormatList) Less(i, j int) bool {
- return c[i].ServiceTemplateId < c[j].ServiceTemplateId
- }
- func (c ContractServiceTemplateFormatList) Swap(i, j int) {
- c[i], c[j] = c[j], c[i]
- }
- func GetContractServiceTemplateFullName() (items []*ContractServiceTemplateFullName, err error) {
- err = global.DEFAULT_MYSQL.Table("contract_service_template as t1").
- Select("t1.*, t2.title as parent_title").
- Joins(" left join contract_service_template as t2 on t1.pid = t2.service_template_id").
- Where("t1.is_delete = 0").
- Order("t1.service_template_id ASC").
- Find(&items).Error
- return
- }
- // GetContractServiceTemplateByTitle 用名称获取合同套餐模板
- func GetContractServiceTemplateByTitle(titles string) (items []*ContractServiceTemplate, err error) {
- err = global.DEFAULT_MYSQL.Model(ContractServiceTemplate{}).
- Where("title IN (?)", titles).
- Scan(&items).Error
- return
- }
|