57 lines
2.1 KiB
Go
57 lines
2.1 KiB
Go
|
package kafka
|
|||
|
|
|||
|
import (
|
|||
|
"context"
|
|||
|
"encoding/json"
|
|||
|
"finclip-app-manager/infrastructure/config"
|
|||
|
uuid "github.com/satori/go.uuid"
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
//tam备案
|
|||
|
type TamRecordContent struct {
|
|||
|
OrganId string `json:"organId"` //机构id
|
|||
|
OrganName string `json:"organName"` //机构名称
|
|||
|
SocialCreditCode string `json:"socialCreditCode"` //社会信用代码
|
|||
|
OrganType string `json:"organType"` //机构类型
|
|||
|
OrganProperty string `json:"organProperty"` //机构性质
|
|||
|
Address string `json:"address"` //地址
|
|||
|
Phone string `json:"phone"` //电话
|
|||
|
Email string `json:"email"` //email
|
|||
|
Website string `json:"website"` //网址
|
|||
|
Foundation string `json:"foundation"` //成立时间
|
|||
|
}
|
|||
|
|
|||
|
type TamBaseContent struct {
|
|||
|
Id string `json:"id"` //业务层防止重复消费
|
|||
|
DataType int `json:"dataType"` //数据类型,1:备案;2:异常数据上报
|
|||
|
Data TamRecordContent `json:"data"`
|
|||
|
}
|
|||
|
|
|||
|
func GenTamRecordContentData(ctx context.Context, organId, owner, socialCreditCode string) error {
|
|||
|
if producer == nil {
|
|||
|
return nil
|
|||
|
}
|
|||
|
|
|||
|
var tamBaseContent TamBaseContent
|
|||
|
tamBaseContent.Id = uuid.NewV4().String()
|
|||
|
tamBaseContent.DataType = 1
|
|||
|
tamBaseContent.Data.OrganId = organId
|
|||
|
tamBaseContent.Data.OrganName = owner
|
|||
|
tamBaseContent.Data.SocialCreditCode = socialCreditCode //需要改造成应用所属企业社会编码
|
|||
|
tamBaseContent.Data.OrganType = "2"
|
|||
|
tamBaseContent.Data.OrganProperty = "1"
|
|||
|
tamBaseContent.Data.Address = "深圳市南山区侨香路4080号·侨城坊1栋26~33楼"
|
|||
|
tamBaseContent.Data.Phone = "0755-8318 3333"
|
|||
|
tamBaseContent.Data.Email = "ccs@sscc.com"
|
|||
|
tamBaseContent.Data.Website = "https://open.fdep.cn/#/"
|
|||
|
|
|||
|
nowTime := time.Now().UnixNano() / 1000000
|
|||
|
timeFormat := "2006-01-02 15:04:05"
|
|||
|
tamBaseContent.Data.Foundation = time.Unix(nowTime/1000, 0).Format(timeFormat)
|
|||
|
|
|||
|
jsonBytes, _ := json.Marshal(tamBaseContent)
|
|||
|
|
|||
|
return sendMsg(ctx, config.GetConfig().KafkaTamTopic, string(jsonBytes))
|
|||
|
}
|