123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- package fms
- import (
- "hongze/fms_api/global"
- "hongze/fms_api/models/base"
- )
- // ContractService 合同服务套餐
- type ContractService struct {
- ContractServiceId int `gorm:"primaryKey;column:contract_service_id" json:"contract_service_id"`
- ContractRegisterId int `gorm:"column:contract_register_id" json:"contract_register_id" description:"登记ID"`
- ProductId int `gorm:"column:product_id" json:"product_id" description:"产品ID"`
- ServiceTemplateId int `gorm:"column:service_template_id" json:"service_template_id" description:"合同服务模板ID"`
- Title string `gorm:"column:title" json:"title" description:"套餐名称"`
- Value string `gorm:"column:value" json:"value" description:"套餐的值"`
- TableValue string `gorm:"column:table_value" json:"table_value" description:"表格数据,用于word生成时的json数据"`
- HasDetail string `gorm:"column:has_detail" json:"has_detail" description:"是否有详情: 无; 有"`
- ChartPermissionId int `gorm:"column:chart_permission_id" json:"chart_permission_id" description:"权限ID"`
- ChartPermissionIds string `gorm:"column:chart_permission_ids" json:"chart_permission_ids" description:"权限IDs-小套餐"`
- base.TimeBase
- }
- type ContractServiceWithParentTitle struct {
- ContractService
- Pid int
- ParentTitle string
- }
- func (c *ContractService) TableName() string {
- return "contract_service"
- }
- func (c *ContractService) List(condition string, pars []interface{}) (list []*ContractService, err error) {
- list = make([]*ContractService, 0)
- err = global.DEFAULT_MYSQL.Model(c).
- Where(condition, pars...).
- Find(&list).Error
- return
- }
- func (c *ContractService) ListWithWithParentTitle(condition string, pars []interface{}) (list []*ContractServiceWithParentTitle, err error) {
- list = make([]*ContractServiceWithParentTitle, 0)
- err = global.DEFAULT_MYSQL.Table("contract_service as cv").
- Select("cv.*, t1.pid, t2.title as parent_title").
- Joins(" left join contract_service_template as t1 on cv.service_template_id = t1.service_template_id").
- Joins(" left join contract_service_template as t2 on t1.pid = t2.service_template_id").
- Where(condition, pars...).
- Find(&list).Error
- return
- }
- // ContractServiceAddReq 新增合同套餐请求体
- type ContractServiceAddReq struct {
- ServiceTemplateId int `json:"service_template_id" description:"服务套餐id"`
- Title string `json:"title" description:"服务套餐名称"`
- Value string `json:"value" description:"服务套餐内容"`
- ChartPermissionIds string `json:"chart_permission_ids" description:"品种权限"`
- //Detail [][]ContractServiceDetailAddReq `json:"detail" description:"详情数据"`
- }
- // ContractServiceItem 合同的服务内容
- type ContractServiceItem struct {
- ContractServiceId int `json:"contract_service_id" description:"合同服务ID"`
- ContractRegisterId int `json:"contract_register_id" description:"合同登记ID"`
- ProductId int `json:"product_id" description:"产品id,1:ficc;2:权益"`
- ServiceTemplateId int `json:"service_template_id" description:"合同服务模板id"`
- Title string `json:"title" description:"套餐标题"`
- Value string `json:"value" description:"套餐的值"`
- HasDetail string `json:"has_detail" description:"是否有详情,枚举值:是、否;默认:否"`
- TableValue string `json:"table_value" description:"表格数据,用于word生成时的json数据"`
- ChartPermissionId int `json:"chart_permission_id" description:"权限id"`
- ChartPermissionIds string `json:"chart_permission_ids" description:"品种权限-小套餐"`
- }
- // ContractServiceAndDetail 合同的服务内容及详情
- type ContractServiceAndDetail struct {
- ContractServiceId int `json:"contract_service_id" description:"合同服务ID"`
- ContractRegisterId int `json:"contract_register_id" description:"合同登记ID"`
- ProductId int `json:"product_id" description:"产品id,1:ficc;2:权益"`
- ServiceTemplateId int `json:"service_template_id" description:"合同服务模板id"`
- Title string `json:"title" description:"套餐标题"`
- Value string `json:"value" description:"套餐的值"`
- HasDetail string `json:"has_detail" description:"是否有详情,枚举值:是、否;默认:否"`
- TableValue string `json:"table_value" description:"表格数据,用于word生成时的json数据"`
- ChartPermissionId int `json:"chart_permission_id" description:"权限id"`
- ChartPermissionIds string `json:"chart_permission_ids" description:"品种权限-小套餐"`
- //Detail []*ContractServiceDetail `json:"detail"`
- }
- // GetContractServiceAndDetailList 根据id获取合同列表数据
- func GetContractServiceAndDetailList(contractRegisterId int) (list []*ContractServiceAndDetail, err error) {
- items := make([]*ContractServiceItem, 0)
- err = global.DEFAULT_MYSQL.Model(ContractService{}).
- Where("contract_register_id = ?", contractRegisterId).
- Find(&items).Error
- if err != nil {
- return
- }
- list = formatContractServiceAndDetailList(items)
- return
- }
- // formatContractServiceAndDetailList 格式化ContractServiceAndDetailList
- func formatContractServiceAndDetailList(list []*ContractServiceItem) (itemList []*ContractServiceAndDetail) {
- itemList = make([]*ContractServiceAndDetail, 0)
- for i := range list {
- itemList = append(itemList, &ContractServiceAndDetail{
- ContractServiceId: list[i].ContractServiceId,
- ContractRegisterId: list[i].ContractRegisterId,
- ProductId: list[i].ProductId,
- ServiceTemplateId: list[i].ServiceTemplateId,
- Title: list[i].Title,
- Value: list[i].Value,
- HasDetail: list[i].HasDetail,
- TableValue: list[i].TableValue,
- ChartPermissionId: list[i].ChartPermissionId,
- ChartPermissionIds: list[i].ChartPermissionIds,
- })
- }
- return
- }
- // GetContractRegisterIdsByTempId 套餐模板ID获取关联的合同登记ID
- func GetContractRegisterIdsByTempId(tempIds []string) (registerIds []int, err error) {
- err = global.DEFAULT_MYSQL.Model(ContractService{}).
- Select("DISTINCT contract_register_id").
- Where("service_template_id in (?)", tempIds).
- Find(®isterIds).Error
- return
- }
- // ContractRegisterServicesName 合同登记套餐信息
- type ContractRegisterServicesName struct {
- ContractRegisterId int `json:"contract_register_id" description:"登记ID"`
- ServicesName string `json:"services_name" description:"套餐信息, 英文逗号拼接"`
- }
- // GetContractRegisterServicesNameByRegisterIds 合同登记IDs获取套餐拼接字符串
- func GetContractRegisterServicesNameByRegisterIds(registerIds []int) (list []*ContractRegisterServicesName, err error) {
- list = make([]*ContractRegisterServicesName, 0)
- err = global.DEFAULT_MYSQL.Model(ContractService{}).
- Select("contract_register_id, GROUP_CONCAT(title) AS services_name").
- Where("contract_register_id IN ? ", registerIds).
- Group("contract_register_id").
- Find(&list).Error
- return
- }
- // GetContractRegisterServicesByRegisterIds 合同登记IDs获取套餐拼接字符串
- func GetContractRegisterServicesByRegisterIds(registerIds []int) (list []*ContractService, err error) {
- err = global.DEFAULT_MYSQL.Model(ContractService{}).
- Select("*").
- Where("contract_register_id IN ?", registerIds).
- Find(&list).Error
- return
- }
|