notice_setting_param.go 7.3 KB
package domain

import "errors"

//NoticeModule 消息模块
type NoticeModule struct {
	ModuleCode string `json:"moduleCode"`
	ModuleName string `json:"moduleName"`
}

//NoticeModuleAction 业务环节
type NoticeModuleAction struct {
	ModuleCode string `json:"moduleCode"`
	ActionCode string `json:"actionCode"`
	ActionName string `json:"actionName"`
}

// 编排消息需要的变量
type NoticeSettingParam struct {
	// 变量的代码标识
	ParamCode string `json:"paramCode"`
	// 变量名称描述
	ParamName string `json:"paramName"`
	// 业务环节
	ModuleAction string `json:"moduleAction"`
	// 消息对应的业务模块
	Module string `json:"module"`
}

//GetNoticeModuleList 获取消息模块列表
func GetNoticeModuleList() []NoticeModule {
	return noticeModuleList
}

//GetNoticeModuleActionList 获取业务环节列表
func GetNoticeModuleActionList() []NoticeModuleAction {
	return noticeModuleActionList
}

//GetNoticeSettingParamList 获取变量列表
func GetNoticeSettingParamList(actionCode string) []NoticeSettingParam {
	if len(actionCode) == 0 {
		return noticeSettingParamList
	}
	var list []NoticeSettingParam
	for i := range noticeSettingParamList {
		if noticeSettingParamList[i].ModuleAction == actionCode {
			list = append(list, noticeSettingParamList[i])
		}
	}
	return list
}

//ValidNoticeModule 校验NoticeModule编码
func ValidNoticeModule(code string) bool {
	for i := range noticeModuleList {
		if noticeModuleList[i].ModuleCode == code {
			return true
		}
	}
	return false
}

//ValidNoticeModuleAction 校验NoticeModuleAction编码
func ValidNoticeModuleAction(moduleCode string, actioncode string) bool {
	for i := range noticeModuleActionList {
		if (noticeModuleActionList[i].ActionCode == actioncode) &&
			(noticeModuleActionList[i].ModuleCode == moduleCode) {
			return true
		}
	}
	return false
}

func GetNoticeModuleAction(moduleCode string, actioncode string) (NoticeModuleAction, error) {
	for i := range noticeModuleActionList {
		if (noticeModuleActionList[i].ActionCode == actioncode) &&
			(noticeModuleActionList[i].ModuleCode == moduleCode) {
			return noticeModuleActionList[i], nil
		}
	}
	return NoticeModuleAction{}, errors.New("未找到对应的消息动作")
}

func GetNoticeModule(moduleCode string) (NoticeModule, error) {
	for i := range noticeModuleList {
		if noticeModuleList[i].ModuleCode == moduleCode {
			return noticeModuleList[i], nil
		}
	}
	return NoticeModule{}, errors.New("未找到对应的消息模块")
}

//业务模块
const (
	Module00 = "module00" // 系统消息
	Module01 = "module01" // 天联共创
)

//业务环节
const (
	Action00_01 = "action00_01" //系统消息
	Action01_01 = "action01_01" //天联共创-共创申请审核通过
	Action01_02 = "action01_02" //天联共创-共创申请审核拒绝
	Action01_03 = "action01_03" //天联共创-共创确认
	Action01_04 = "action01_04" //天联共创-分红预算消息
	Action01_05 = "action01_05" //天联共创-账期结算消息
	Action01_06 = "action01_06" //天联共创-支付消息
)

//业务环节变量
const (
	Param01_01_01 = "param01_01_01" //共创申请通过-共创项目编号
	Param01_01_02 = "param01_01_02" //共创申请通过-共创项目名称

	Param01_02_01 = "param01_02_01" //共创申请拒绝-共创项目编号
	Param01_02_02 = "param01_02_02" //共创申请拒绝-共创项目名称

	Param01_03_01 = "param01_03_01" //共创确认-共创项目编号
	Param01_03_02 = "param01_03_02" //共创确认-共创项目名称
	Param01_03_03 = "param01_03_03" //共创确认-项目合约编号
	Param01_03_04 = "param01_03_04" //共创确认-项目合约名称

	Param01_04_01 = "param01_04_01" //分红预算消息-共创项目编号
	Param01_04_02 = "param01_04_02" //分红预算消息-共创项目名称
	Param01_04_03 = "param01_04_03" //分红预算消息-项目合约编号
	Param01_04_04 = "param01_04_04" //分红预算消息-项目合约名称
	Param01_04_05 = "param01_04_05" //分红预算消息-订单产品信息
	Param01_04_06 = "param01_04_06" //分红预算消息-分红金额

	Param01_05_01 = "param01_05_01" //账期结算消息-账期结算单号
	Param01_05_02 = "param01_05_02" //账期结算消息-结算金额
	Param01_05_03 = "param01_05_03" //账期结算消息-分红预算单号

	Param01_06_01 = "param01_06_01" //支付消息-账期结算单号
	Param01_06_02 = "param01_06_02" //支付消息-结算金额
	Param01_06_03 = "param01_06_03" //支付消息-实付金额
)

//noticeModuleList 模块列表
var noticeModuleList = []NoticeModule{
	{ModuleCode: Module01, ModuleName: "天联共创"},
}

//noticeModuleActionList 业务环节列表
var noticeModuleActionList = []NoticeModuleAction{
	{ModuleCode: Module00, ActionCode: Action00_01, ActionName: "系统消息"},
	{ModuleCode: Module01, ActionCode: Action01_01, ActionName: "共创申请通过"},
	{ModuleCode: Module01, ActionCode: Action01_02, ActionName: "共创申请拒绝"},
	{ModuleCode: Module01, ActionCode: Action01_03, ActionName: "共创确认"},
	{ModuleCode: Module01, ActionCode: Action01_04, ActionName: "分红预算消息"},
	{ModuleCode: Module01, ActionCode: Action01_05, ActionName: "账期结算消息"},
	{ModuleCode: Module01, ActionCode: Action01_06, ActionName: "支付消息"},
}

//noticeSettingParamList 业务变量列表
var noticeSettingParamList = []NoticeSettingParam{
	{Module: Module01, ModuleAction: Action01_01, ParamCode: Param01_01_01, ParamName: "共创项目编号"},
	{Module: Module01, ModuleAction: Action01_01, ParamCode: Param01_01_02, ParamName: "共创项目名称"},

	{Module: Module01, ModuleAction: Action01_02, ParamCode: Param01_02_01, ParamName: "共创项目编号"},
	{Module: Module01, ModuleAction: Action01_02, ParamCode: Param01_02_02, ParamName: "共创项目名称"},

	{Module: Module01, ModuleAction: Action01_03, ParamCode: Param01_03_01, ParamName: "共创项目编号"},
	{Module: Module01, ModuleAction: Action01_03, ParamCode: Param01_03_02, ParamName: "共创项目名称"},
	{Module: Module01, ModuleAction: Action01_03, ParamCode: Param01_03_03, ParamName: "项目合约编号"},
	{Module: Module01, ModuleAction: Action01_03, ParamCode: Param01_03_04, ParamName: "项目合约名称"},

	{Module: Module01, ModuleAction: Action01_04, ParamCode: Param01_04_01, ParamName: "共创项目编号"},
	{Module: Module01, ModuleAction: Action01_04, ParamCode: Param01_04_02, ParamName: "共创项目名称"},
	{Module: Module01, ModuleAction: Action01_04, ParamCode: Param01_04_03, ParamName: "项目合约编号"},
	{Module: Module01, ModuleAction: Action01_04, ParamCode: Param01_04_04, ParamName: "项目合约名称"},
	{Module: Module01, ModuleAction: Action01_04, ParamCode: Param01_04_05, ParamName: "订单产品信息"},
	{Module: Module01, ModuleAction: Action01_04, ParamCode: Param01_04_06, ParamName: "分红金额"},

	{ModuleAction: Module01, Module: Action01_05, ParamCode: Param01_05_01, ParamName: "账期结算单号"},
	{ModuleAction: Module01, Module: Action01_05, ParamCode: Param01_05_02, ParamName: "结算金额"},
	{ModuleAction: Module01, Module: Action01_05, ParamCode: Param01_05_03, ParamName: "分红预算单号"},

	{ModuleAction: Module01, Module: Action01_06, ParamCode: Param01_06_01, ParamName: "账期结算单号"},
	{ModuleAction: Module01, Module: Action01_06, ParamCode: Param01_06_02, ParamName: "结算金额"},
	{ModuleAction: Module01, Module: Action01_06, ParamCode: Param01_06_03, ParamName: "实付金额"},
}