xiziwen 7 月之前
父節點
當前提交
9bc9ffae02

+ 32 - 2
controllers/seal.go

@@ -12,6 +12,7 @@ import (
 	"hongze/hongze_mobile_admin/utils"
 	"path"
 	"strconv"
+	"strings"
 )
 
 //SealCommon
@@ -59,8 +60,11 @@ func (c *SealCommon) Add() {
 		c.FailWithMessage("合同附件不能为空", "合同附件不能为空")
 		return
 	}
+	if req.AffiliatedCompany == "" {
+		c.FailWithMessage("归属公司不能为空", "归属公司不能为空")
+	}
 
-	sealInfo, err := sealService.AddSeal(c.AdminWx.AdminId, req.ContractId, req.FileNum, c.AdminWx.RealName, req.Use, req.UseCompanyName, req.CompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls)
+	sealInfo, err := sealService.AddSeal(c.AdminWx.AdminId, req.ContractId, req.FileNum, c.AdminWx.RealName, req.Use, req.UseCompanyName, req.CompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, req.AffiliatedCompany)
 	if err != nil {
 		c.FailWithMessage("用印添加失败", err.Error())
 		return
@@ -119,8 +123,11 @@ func (c *SealCommon) Edit() {
 		c.FailWithMessage("合同附件不能为空", "合同附件不能为空")
 		return
 	}
+	if req.AffiliatedCompany == "" {
+		c.FailWithMessage("归属公司不能为空", "归属公司不能为空")
+	}
 
-	sealInfo, err := sealService.Edit(req.SealId, c.AdminWx.AdminId, req.ContractId, req.FileNum, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, c.AdminWx.RealName)
+	sealInfo, err := sealService.Edit(req.SealId, c.AdminWx.AdminId, req.ContractId, req.FileNum, req.Use, req.CompanyName, req.UseCompanyName, req.CreditCode, req.ServiceType, req.SealType, req.Remark, req.FileUrls, c.AdminWx.RealName, req.AffiliatedCompany)
 	if err != nil {
 		c.FailWithMessage("修改合同失败!", "修改合同失败,Err:"+err.Error())
 		return
@@ -204,6 +211,7 @@ func (c *SealCommon) List() {
 	adminIds := c.GetString("AdminId")
 	keyword := c.GetString("Keyword")
 	keywordEq := c.GetString("KeywordEq")
+	affiliatedCompany := c.GetString("AffiliatedCompany")
 
 	condition := ""
 	pars := make([]interface{}, 0)
@@ -247,6 +255,11 @@ func (c *SealCommon) List() {
 		condition += ` AND (c.use_company_name =? OR c.company_name =?) `
 		pars = append(pars, keywordEq, keywordEq)
 	}
+	// 归属公司
+	if affiliatedCompany != "" {
+		condition += ` AND affiliated_company =? `
+		pars = append(pars, affiliatedCompany)
+	}
 
 	pageSize, _ := c.GetInt("PageSize")
 	currentIndex, _ := c.GetInt("CurrentIndex")
@@ -473,5 +486,22 @@ func (c *SealCommon) CompanyNameList() {
 		return
 	}
 
+	c.OkDetailed(list, "获取成功")
+}
+
+// 关联公司列表
+// @Title 关联公司列表
+// @Description 关联公司列表
+// @Success 200 {object} response.SealApprovalListResp
+// @router /getAffiliatedCompany [get]
+func (c *SealCommon) AffiliatedCompanyList() {
+
+	crmConfig, err := company.GetConfigDetailByCode("affiliated_company")
+	if err != nil {
+		c.FailWithMessage( "获取配置失败!", "获取配置失败,Err:"+err.Error())
+		return
+	}
+	list := strings.Split(crmConfig.ConfigValue, ",")
+
 	c.OkDetailed(list, "获取成功")
 }

+ 26 - 24
models/request/seal/sale.go

@@ -1,35 +1,37 @@
 package seal
 
-//新增用印请求
+// 新增用印请求
 type AddReq struct {
-	ContractId     int      `description:"系统合同id"`
-	Use            string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
-	CompanyName    string   `description:"客户名称,甲方名称,长度32位"`
-	UseCompanyName string   `description:"实际适用方客户名称,长度32位"`
-	CreditCode     string   `description:"社会统一信用代码,长度64位"`
-	ServiceType    string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
-	SealType       string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
-	Remark         string   `description:"备注,长度255位"`
-	FileUrls       []string `description:"多个文件附件地址"`
-	FileNum        int      `description:"文件份数"`
+	ContractId        int      `description:"系统合同id"`
+	Use               string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
+	CompanyName       string   `description:"客户名称,甲方名称,长度32位"`
+	UseCompanyName    string   `description:"实际适用方客户名称,长度32位"`
+	CreditCode        string   `description:"社会统一信用代码,长度64位"`
+	ServiceType       string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
+	SealType          string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
+	Remark            string   `description:"备注,长度255位"`
+	FileUrls          []string `description:"多个文件附件地址"`
+	FileNum           int      `description:"文件份数"`
+	AffiliatedCompany string   `description:"归属公司"`
 }
 
-//编辑用印请求
+// 编辑用印请求
 type EditReq struct {
-	SealId         int      `description:"用印id"`
-	ContractId     int      `description:"系统合同id"`
-	Use            string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
-	CompanyName    string   `description:"客户名称,甲方名称,长度32位"`
-	UseCompanyName string   `description:"实际适用方客户名称,长度32位"`
-	CreditCode     string   `description:"社会统一信用代码,长度64位"`
-	ServiceType    string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
-	SealType       string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
-	Remark         string   `description:"备注,长度255位"`
-	FileUrls       []string `description:"文件附件地址"`
-	FileNum        int      `description:"文件份数"`
+	SealId            int      `description:"用印id"`
+	ContractId        int      `description:"系统合同id"`
+	Use               string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`
+	CompanyName       string   `description:"客户名称,甲方名称,长度32位"`
+	UseCompanyName    string   `description:"实际适用方客户名称,长度32位"`
+	CreditCode        string   `description:"社会统一信用代码,长度64位"`
+	ServiceType       string   `description:"业务类型,枚举值:'新签合同','续约合同','补充协议';默认:新签合同"`
+	SealType          string   `description:"加盖印章类型,枚举值:'合同章', '公章', '法人章';默认:合同章"`
+	Remark            string   `description:"备注,长度255位"`
+	FileUrls          []string `description:"文件附件地址"`
+	FileNum           int      `description:"文件份数"`
+	AffiliatedCompany string   `description:"归属公司"`
 }
 
-//审批者编辑用印请求
+// 审批者编辑用印请求
 type CheckEditReq struct {
 	SealId   int      `description:"用印单id"`
 	Use      string   `description:"用印用途,枚举值:'销售合同', '渠道合同', '付款通知函', '招投标', '战略合作协议';默认:销售合同"`

+ 82 - 0
models/tables/company/company_config.go

@@ -0,0 +1,82 @@
+package company
+
+import (
+	"encoding/json"
+	"errors"
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_mobile_admin/utils"
+)
+
+const (
+	ConfAreaCodeListKey = "area_code_list" // 手机号区号列表
+)
+
+type CrmConfig struct {
+	ConfigCode  string `description:"详情Code"`
+	ConfigValue string `description:"详情"`
+}
+
+func GetConfigValueByCode(configCode string) (total int, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT config_value FROM crm_config WHERE config_code=? `
+	err = o.Raw(sql, configCode).QueryRow(&total)
+	return
+}
+
+// 修改
+func CrmConfigUpdate(newValue, configCode string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE crm_config SET  config_value=?   WHERE config_code=  ?`
+	_, err = o.Raw(sql, newValue, configCode).Exec()
+	return
+}
+
+// ConfigClassifyId
+// @Description: 后台配置的报告id
+type ConfigClassifyId struct {
+	Debug   int `json:"debug"`
+	Release int `json:"release"`
+}
+
+func GetConfigDetailByCode(configCode string) (item CrmConfig, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM crm_config WHERE config_code=? `
+	err = o.Raw(sql, configCode).QueryRow(&item)
+	return
+}
+
+// GetReportClassifyIdByConfigKey
+// @Description: 获取关联的报告id
+// @author: Roc
+// @datetime 2024-06-18 14:10:27
+// @param configKey string
+// @return classifyId int
+// @return err error
+func GetReportClassifyIdByConfigKey(configKey string) (classifyId int, err error) {
+	// 别问为啥要从配置里拿=_=!
+	conf, e := GetConfigDetailByCode(configKey)
+	if e != nil {
+		err = errors.New("获取配置的id失败, Err: " + e.Error())
+		return
+	}
+	if conf.ConfigValue == "" {
+		err = errors.New("ID配置有误")
+		return
+	}
+	type TwoWeekIdConf struct {
+		Debug   []int
+		Release []int
+	}
+	classifyIdConf := new(ConfigClassifyId)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &classifyIdConf); e != nil {
+		err = errors.New("解析ID配置失败, Err: " + e.Error())
+		return
+	}
+	if utils.RunMode == "debug" {
+		classifyId = classifyIdConf.Debug
+	} else {
+		classifyId = classifyIdConf.Release
+	}
+
+	return
+}

+ 1 - 0
models/tables/seal/seal.go

@@ -32,6 +32,7 @@ type Seal struct {
 	ModifyTime        time.Time `description:"最近一次修改时间"`
 	CreateTime        time.Time `description:"添加时间"`
 	CheckBackFileTime time.Time `description:"签回用印附件时间"`
+	AffiliatedCompany string    `description:"归属公司"`
 }
 
 var EnumUse = []string{"销售合同", "渠道合同", "付款通知函", "招投标", "战略合作协议", "代付合同", "总对总协议"}

+ 9 - 0
routers/commentsRouter.go

@@ -763,6 +763,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"],
+        beego.ControllerComments{
+            Method: "AffiliatedCompanyList",
+            Router: `/getAffiliatedCompany`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_mobile_admin/controllers:SealCommon"],
         beego.ControllerComments{
             Method: "Invalid",

+ 5 - 3
services/seal/seal.go

@@ -21,7 +21,7 @@ import (
 )
 
 // AddSeal 添加用印
-func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, companyName, creditCode, serviceType, sealType, remark string, fileUrls []string) (sealInfo *seal.Seal, err error) {
+func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, companyName, creditCode, serviceType, sealType, remark string, fileUrls []string, affiliatedCompany string) (sealInfo *seal.Seal, err error) {
 	o := orm.NewOrm()
 	to, err := o.Begin()
 	if err != nil {
@@ -70,6 +70,7 @@ func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, com
 		ContractId:     contractId,
 		ModifyTime:     now,
 		CreateTime:     now,
+		AffiliatedCompany: affiliatedCompany,
 	}
 	err = seal.AddSeal(sealInfo)
 	if err != nil {
@@ -104,7 +105,7 @@ func AddSeal(userId, contractId, fileNum int, userName, use, useCompanyName, com
 }
 
 // Edit 修改用印
-func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string, userName string) (sealInfo *seal.Seal, err error) {
+func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompanyName, creditCode, serviceType, sealType, remark string, fileUrls []string, userName string, affiliatedCompany string) (sealInfo *seal.Seal, err error) {
 	o := orm.NewOrm()
 	to, err := o.Begin()
 	if err != nil {
@@ -163,8 +164,9 @@ func Edit(sealId, userId, contractId, fileNum int, use, companyName, userCompany
 	sealInfo.CreateTime = now	// 重提更新提交时间
 	sealInfo.ModifyTime = now
 	sealInfo.Status = "待提交" //用印状态
+	sealInfo.AffiliatedCompany = affiliatedCompany
 
-	err = sealInfo.Update([]string{"Use", "CompanyName", "UseCompanyName", "CreditCode", "ServiceType", "SealType", "Remark", "FileUrl", "FileNum", "ContractId", "CreateTime", "ModifyTime", "Status"})
+	err = sealInfo.Update([]string{"Use", "CompanyName", "UseCompanyName", "CreditCode", "ServiceType", "SealType", "Remark", "FileUrl", "FileNum", "ContractId", "CreateTime", "ModifyTime", "Status", "AffiliatedCompany"})
 	if err != nil {
 		err = errors.New("新增用印日志失败")
 		return