fuwencai 5 сар өмнө
parent
commit
f73a2d6c0e

+ 2 - 3
newuserGet/internal/logic/task.go

@@ -40,7 +40,7 @@ func Task(ctx context.Context) {
 		}
 		if rules[i].CallState != "" {
 			// 过滤外呼状态
-			userList, err = filterCallState(ctx,rules[i], userList)
+			userList, err = filterCallState(ctx, rules[i], userList)
 			if err != nil {
 				g.Log().Error(ctx, err)
 				continue
@@ -56,7 +56,6 @@ func Task(ctx context.Context) {
 		}
 
 		if len(userList) > 0 {
-
 			// 保存用户
 			_, err = dao.NewUserSendLog.Ctx(ctx).Data(userList).Insert()
 			if err != nil {
@@ -202,7 +201,7 @@ func filterTrailStatus(ctx context.Context, rule entity.NewUserSendRule, userLis
 		}
 		info := entity.DwdFCrmClueInfo{}
 		// 再根据uid 查询
-		err = dao.DwdFCrmClueInfo.Ctx(ctx).Fields("trailstatus,industry").Where("uid=?").Order("trailstatus_time desc").Limit(1).Scan(&info)
+		err = dao.DwdFCrmClueInfo.Ctx(ctx).Fields("trailstatus,industry").Where("uid=?").Order("update_time desc").Limit(1).Scan(&info)
 		if err != nil {
 			g.Log().Error(ctx, "查询跟进状态异常", err)
 			continue

+ 4 - 0
newuserSend/hack/config.yaml

@@ -7,6 +7,10 @@ gfcli:
       - link: "mysql:root:=PDT49#80Z!RVv52_z@tcp(192.168.3.14:4000)/jianyu"
         descriptionTag: true
         tables: "new_user_send_log,new_user_send_content"
+      - link: "mysql:datagroup:Dgrpdb#2024@36@tcp(192.168.3.149:4000)/jianyu_subjectdb_test"
+        descriptionTag: true
+        tables: "d_scopeclass_code"
+        group: crm
   docker:
     build: "-a amd64 -s linux -p temp -ew"
     tagPrefixes:

+ 27 - 0
newuserSend/internal/dao/d_scopeclass_code.go

@@ -0,0 +1,27 @@
+// =================================================================================
+// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
+// =================================================================================
+
+package dao
+
+import (
+	"newuserSend/internal/dao/internal"
+)
+
+// internalDScopeclassCodeDao is an internal type for wrapping the internal DAO implementation.
+type internalDScopeclassCodeDao = *internal.DScopeclassCodeDao
+
+// dScopeclassCodeDao is the data access object for the table d_scopeclass_code.
+// You can define custom methods on it to extend its functionality as needed.
+type dScopeclassCodeDao struct {
+	internalDScopeclassCodeDao
+}
+
+var (
+	// DScopeclassCode is a globally accessible object for table d_scopeclass_code operations.
+	DScopeclassCode = dScopeclassCodeDao{
+		internal.NewDScopeclassCodeDao(),
+	}
+)
+
+// Add your custom methods and functionality below.

+ 89 - 0
newuserSend/internal/dao/internal/d_scopeclass_code.go

@@ -0,0 +1,89 @@
+// ==========================================================================
+// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+
+	"github.com/gogf/gf/v2/database/gdb"
+	"github.com/gogf/gf/v2/frame/g"
+)
+
+// DScopeclassCodeDao is the data access object for the table d_scopeclass_code.
+type DScopeclassCodeDao struct {
+	table   string                 // table is the underlying table name of the DAO.
+	group   string                 // group is the database configuration group name of the current DAO.
+	columns DScopeclassCodeColumns // columns contains all the column names of Table for convenient usage.
+}
+
+// DScopeclassCodeColumns defines and stores column names for the table d_scopeclass_code.
+type DScopeclassCodeColumns struct {
+	Code    string // 分类代码
+	Pcode   string // 父级代码
+	Level   string // 分类级别
+	Name    string // 分类名称
+	Remark  string // 备注
+	SzLevel string //
+	SzLeaf  string //
+	SzPid0  string //
+	SzPid1  string //
+}
+
+// dScopeclassCodeColumns holds the columns for the table d_scopeclass_code.
+var dScopeclassCodeColumns = DScopeclassCodeColumns{
+	Code:    "code",
+	Pcode:   "pcode",
+	Level:   "level",
+	Name:    "name",
+	Remark:  "remark",
+	SzLevel: "SZ_LEVEL",
+	SzLeaf:  "SZ_LEAF",
+	SzPid0:  "SZ_PID0",
+	SzPid1:  "SZ_PID1",
+}
+
+// NewDScopeclassCodeDao creates and returns a new DAO object for table data access.
+func NewDScopeclassCodeDao() *DScopeclassCodeDao {
+	return &DScopeclassCodeDao{
+		group:   "crm",
+		table:   "d_scopeclass_code",
+		columns: dScopeclassCodeColumns,
+	}
+}
+
+// DB retrieves and returns the underlying raw database management object of the current DAO.
+func (dao *DScopeclassCodeDao) DB() gdb.DB {
+	return g.DB(dao.group)
+}
+
+// Table returns the table name of the current DAO.
+func (dao *DScopeclassCodeDao) Table() string {
+	return dao.table
+}
+
+// Columns returns all column names of the current DAO.
+func (dao *DScopeclassCodeDao) Columns() DScopeclassCodeColumns {
+	return dao.columns
+}
+
+// Group returns the database configuration group name of the current DAO.
+func (dao *DScopeclassCodeDao) Group() string {
+	return dao.group
+}
+
+// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
+func (dao *DScopeclassCodeDao) Ctx(ctx context.Context) *gdb.Model {
+	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
+}
+
+// Transaction wraps the transaction logic using function f.
+// It rolls back the transaction and returns the error if function f returns a non-nil error.
+// It commits the transaction and returns nil if function f returns nil.
+//
+// Note: Do not commit or roll back the transaction in function f,
+// as it is automatically handled by this function.
+func (dao *DScopeclassCodeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
+	return dao.Ctx(ctx).Transaction(ctx, f)
+}

+ 26 - 20
newuserSend/internal/dao/internal/new_user_send_content.go

@@ -20,30 +20,36 @@ type NewUserSendContentDao struct {
 
 // NewUserSendContentColumns defines and stores column names for the table new_user_send_content.
 type NewUserSendContentColumns struct {
-	Id          string //
-	RuleId      string // new_user_send_rule的id
-	SendChannel string // 发送渠道:1-短信 2-站内信 3-邮件
-	SmsId       string // 短信模板id
-	SmsVar      string // 短信模板变量,逗号分割
-	MsgUrl      string // 站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,
-	MsgTitle    string //
-	MsgContent  string //
-	CreateTime  string //
-	UpdateTime  string //
+	Id             string //
+	RuleId         string // new_user_send_rule的id
+	SendChannel    string // 发送渠道:1-短信 2-站内信 3-邮件
+	SmsId          string // 短信模板id对应的位置
+	SmsVar         string // 短信模板变量,逗号分割
+	MsgUrl         string // 站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,
+	MsgTitle       string //
+	MsgContent     string //
+	IndustrySmsId  string // 行业短信模板
+	IndustrySmsVar string // 行业短信模板变量
+	CreateTime     string //
+	UpdateTime     string //
+	IndustryMsgUrl string // 有行业的跳转地址
 }
 
 // newUserSendContentColumns holds the columns for the table new_user_send_content.
 var newUserSendContentColumns = NewUserSendContentColumns{
-	Id:          "id",
-	RuleId:      "rule_id",
-	SendChannel: "send_channel",
-	SmsId:       "sms_id",
-	SmsVar:      "sms_var",
-	MsgUrl:      "msg_url",
-	MsgTitle:    "msg_title",
-	MsgContent:  "msg_content",
-	CreateTime:  "create_time",
-	UpdateTime:  "update_time",
+	Id:             "id",
+	RuleId:         "rule_id",
+	SendChannel:    "send_channel",
+	SmsId:          "sms_id",
+	SmsVar:         "sms_var",
+	MsgUrl:         "msg_url",
+	MsgTitle:       "msg_title",
+	MsgContent:     "msg_content",
+	IndustrySmsId:  "industry_sms_id",
+	IndustrySmsVar: "industry_sms_var",
+	CreateTime:     "create_time",
+	UpdateTime:     "update_time",
+	IndustryMsgUrl: "industry_msg_url",
 }
 
 // NewNewUserSendContentDao creates and returns a new DAO object for table data access.

+ 2 - 0
newuserSend/internal/dao/internal/new_user_send_log.go

@@ -27,6 +27,7 @@ type NewUserSendLogColumns struct {
 	State      string // 发送状态:-1 :取消发送 0:待发送 1:已发送
 	CreateTime string //
 	UpdateTime string //
+	Industry   string // 匹配到的行业
 }
 
 // newUserSendLogColumns holds the columns for the table new_user_send_log.
@@ -38,6 +39,7 @@ var newUserSendLogColumns = NewUserSendLogColumns{
 	State:      "state",
 	CreateTime: "create_time",
 	UpdateTime: "update_time",
+	Industry:   "industry",
 }
 
 // NewNewUserSendLogDao creates and returns a new DAO object for table data access.

+ 62 - 15
newuserSend/internal/logic/task.go

@@ -3,7 +3,9 @@ package logic
 import (
 	"context"
 	"fmt"
+	"github.com/gogf/gf/v2/container/gset"
 	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/os/gctx"
 	"github.com/gogf/gf/v2/os/gtime"
 	"newuserSend/internal/consts"
 	"newuserSend/internal/dao"
@@ -15,7 +17,24 @@ import (
 )
 
 var nsm *utility.StationMessage
+var testSet *gset.Set
+var testSwitch bool
+var IndustryMap map[string]interface{}
 
+func init() {
+	ctx := gctx.New()
+	phones := g.Cfg().MustGet(ctx, "test.phone").Array()
+	testSet = gset.NewFrom(phones, true)
+	testSwitch = g.Cfg().MustGet(ctx, "test.switch").Bool()
+	industry := []entity.DScopeclassCode{}
+	err := dao.DScopeclassCode.Ctx(ctx).Fields("code,name").Where("level=?", 1).Scan(&industry)
+	if err != nil {
+		panic("初始化行业code信息异常")
+	}
+	for i := 0; i < len(industry); i++ {
+		IndustryMap[industry[i].Code] = industry[i].Name
+	}
+}
 func Task(ctx context.Context) {
 	addr := g.Cfg().MustGet(ctx, "siteMsg.addr").String()
 	action := g.Cfg().MustGet(ctx, "siteMsg.action").String()
@@ -79,21 +98,36 @@ func sendMsg(ctx context.Context, content entity.NewUserSendContent, sendUserLis
 }
 
 func sms(ctx context.Context, content entity.NewUserSendContent, sendUserList []entity.NewUserSendLog) {
-	// 处理短信请求数据
-	vardata := []string{}
-	if content.SmsVar != "" {
-		smsvars := strings.Split(content.SmsVar, ",")
-		for i := 0; i < len(smsvars); i++ {
-			switch smsvars[i] {
-			case consts.SmsVarMonth:
-				vardata = append(vardata, fmt.Sprint(gtime.Now().Month()))
-			case consts.SmsVarYear:
-				vardata = append(vardata, fmt.Sprint(gtime.Now().Year()))
+    // todo 处理行业短信模板变量
+	for i := 0; i < len(sendUserList); i++ {
+		smsIDIndex := content.SmsId
+		smsvar := content.SmsVar
+		if sendUserList[i].Industry != "" {
+			smsIDIndex = content.IndustrySmsId
+			smsvar = content.IndustrySmsVar
+		}
+		vardata := []string{}
+		if smsvar != "" {
+			smsvars := strings.Split(smsvar, ",")
+			for i := 0; i < len(smsvars); i++ {
+				switch smsvars[i] {
+				case consts.SmsVarMonth:
+					vardata = append(vardata, fmt.Sprint(gtime.Now().Month()))
+				case consts.SmsVarYear:
+					vardata = append(vardata, fmt.Sprint(gtime.Now().Year()))
+				}
 			}
 		}
-	}
-	for i := 0; i < len(sendUserList); i++ {
-		utility.NewSMSDao(sendUserList[i].Phone, vardata, content.SmsId).SendMsgBySMS(ctx)
+		if testSwitch {
+			if testSet.Contains(sendUserList[i].Phone) {
+				utility.NewSMSDao(sendUserList[i].Phone, vardata, smsIDIndex).SendMsgBySMS(ctx)
+			} else {
+				g.Log().Info(ctx, "测试模式已开启-该手机号不在测试范围:", sendUserList[i].Phone)
+
+			}
+		} else {
+			utility.NewSMSDao(sendUserList[i].Phone, vardata, content.SmsId).SendMsgBySMS(ctx)
+		}
 	}
 	//g.Log().Info(ctx, "sms 发送完成:",sendUserList,content.RuleId)
 
@@ -107,6 +141,7 @@ func siteMsg(ctx context.Context, content entity.NewUserSendContent, sendUserLis
 	msgTitle = strings.ReplaceAll(msgTitle, consts.SiteMsgMonth, monthStr)
 	urls := strings.Split(content.MsgUrl, ",")
 	var pcUrl, androidUrl, iosUrl, weChatUrl string
+	// todo 区分行业跳转地址
 	if len(urls) > 0 {
 		if len(urls) != 4 {
 			pcUrl, androidUrl, iosUrl, weChatUrl = urls[0], urls[0], urls[0], urls[0]
@@ -114,15 +149,27 @@ func siteMsg(ctx context.Context, content entity.NewUserSendContent, sendUserLis
 			pcUrl, androidUrl, iosUrl, weChatUrl = urls[0], urls[1], urls[2], urls[3]
 		}
 	}
+
+	msgType := g.Cfg().MustGet(ctx, "siteMsg.msgType").Int()
 	mgoIds := []string{}
 	for i := 0; i < len(sendUserList); i++ {
-		mgoIds = append(mgoIds, sendUserList[i].UserId)
+		if sendUserList[i].Industry == "" {
+			mgoIds = append(mgoIds, sendUserList[i].UserId)
+		} else {
+			// todo 处理行业跳转
+			//industryUrl := content.IndustryMsgUrl
+			// 有行业的需要单独处理跳转地址
+			//newparm := utility.MessageParam{
+			//	UserIds: sendUserList[i].UserId, Title: msgTitle, Content: msgInfo, Link: pcUrl, AndroidUrl: androidUrl, IosUrl: iosUrl, WeChatUrl: weChatUrl, MsgType: msgType,
+			//}
+			//nsm.SendStationMessages(ctx, newparm)
+		}
 	}
-	msgType := g.Cfg().MustGet(ctx, "siteMsg.msgType").Int()
 	parm := utility.MessageParam{
 		UserIds: strings.Join(mgoIds, ","), Title: msgTitle, Content: msgInfo, Link: pcUrl, AndroidUrl: androidUrl, IosUrl: iosUrl, WeChatUrl: weChatUrl, MsgType: msgType,
 	}
 	nsm.SendStationMessages(ctx, parm)
+	//
 }
 func updateState(ctx context.Context, sendUserList []entity.NewUserSendLog) {
 	ids := []int{}

+ 23 - 0
newuserSend/internal/model/do/d_scopeclass_code.go

@@ -0,0 +1,23 @@
+// =================================================================================
+// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
+// =================================================================================
+
+package do
+
+import (
+	"github.com/gogf/gf/v2/frame/g"
+)
+
+// DScopeclassCode is the golang structure of table d_scopeclass_code for DAO operations like Where/Data.
+type DScopeclassCode struct {
+	g.Meta  `orm:"table:d_scopeclass_code, do:true"`
+	Code    interface{} // 分类代码
+	Pcode   interface{} // 父级代码
+	Level   interface{} // 分类级别
+	Name    interface{} // 分类名称
+	Remark  interface{} // 备注
+	SzLevel interface{} //
+	SzLeaf  interface{} //
+	SzPid0  interface{} //
+	SzPid1  interface{} //
+}

+ 14 - 11
newuserSend/internal/model/do/new_user_send_content.go

@@ -11,15 +11,18 @@ import (
 
 // NewUserSendContent is the golang structure of table new_user_send_content for DAO operations like Where/Data.
 type NewUserSendContent struct {
-	g.Meta      `orm:"table:new_user_send_content, do:true"`
-	Id          interface{} //
-	RuleId      interface{} // new_user_send_rule的id
-	SendChannel interface{} // 发送渠道:1-短信 2-站内信 3-邮件
-	SmsId       interface{} // 短信模板id
-	SmsVar      interface{} // 短信模板变量,逗号分割
-	MsgUrl      interface{} // 站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,
-	MsgTitle    interface{} //
-	MsgContent  interface{} //
-	CreateTime  *gtime.Time //
-	UpdateTime  *gtime.Time //
+	g.Meta         `orm:"table:new_user_send_content, do:true"`
+	Id             interface{} //
+	RuleId         interface{} // new_user_send_rule的id
+	SendChannel    interface{} // 发送渠道:1-短信 2-站内信 3-邮件
+	SmsId          interface{} // 短信模板id对应的位置
+	SmsVar         interface{} // 短信模板变量,逗号分割
+	MsgUrl         interface{} // 站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,
+	MsgTitle       interface{} //
+	MsgContent     interface{} //
+	IndustrySmsId  interface{} // 行业短信模板
+	IndustrySmsVar interface{} // 行业短信模板变量
+	CreateTime     *gtime.Time //
+	UpdateTime     *gtime.Time //
+	IndustryMsgUrl interface{} // 有行业的跳转地址
 }

+ 1 - 0
newuserSend/internal/model/do/new_user_send_log.go

@@ -19,4 +19,5 @@ type NewUserSendLog struct {
 	State      interface{} // 发送状态:-1 :取消发送 0:待发送 1:已发送
 	CreateTime *gtime.Time //
 	UpdateTime *gtime.Time //
+	Industry   interface{} // 匹配到的行业
 }

+ 18 - 0
newuserSend/internal/model/entity/d_scopeclass_code.go

@@ -0,0 +1,18 @@
+// =================================================================================
+// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
+// =================================================================================
+
+package entity
+
+// DScopeclassCode is the golang structure for table d_scopeclass_code.
+type DScopeclassCode struct {
+	Code    string `json:"code"    orm:"code"     description:"分类代码"` // 分类代码
+	Pcode   string `json:"pcode"   orm:"pcode"    description:"父级代码"` // 父级代码
+	Level   string `json:"level"   orm:"level"    description:"分类级别"` // 分类级别
+	Name    string `json:"name"    orm:"name"     description:"分类名称"` // 分类名称
+	Remark  string `json:"remark"  orm:"remark"   description:"备注"`   // 备注
+	SzLevel int64  `json:"sZLEVEL" orm:"SZ_LEVEL" description:""`     //
+	SzLeaf  int64  `json:"sZLEAF"  orm:"SZ_LEAF"  description:""`     //
+	SzPid0  string `json:"sZPID0"  orm:"SZ_PID0"  description:""`     //
+	SzPid1  string `json:"sZPID1"  orm:"SZ_PID1"  description:""`     //
+}

+ 13 - 10
newuserSend/internal/model/entity/new_user_send_content.go

@@ -10,14 +10,17 @@ import (
 
 // NewUserSendContent is the golang structure for table new_user_send_content.
 type NewUserSendContent struct {
-	Id          int         `json:"id"          orm:"id"           description:""`                                              //
-	RuleId      int         `json:"ruleId"      orm:"rule_id"      description:"new_user_send_rule的id"`                         // new_user_send_rule的id
-	SendChannel int         `json:"sendChannel" orm:"send_channel" description:"发送渠道:1-短信 2-站内信 3-邮件"`                          // 发送渠道:1-短信 2-站内信 3-邮件
-	SmsId       int         `json:"smsId"       orm:"sms_id"       description:"短信模板id"`                                        // 短信模板id
-	SmsVar      string      `json:"smsVar"      orm:"sms_var"      description:"短信模板变量,逗号分割"`                                   // 短信模板变量,逗号分割
-	MsgUrl      string      `json:"msgUrl"      orm:"msg_url"      description:"站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,"` // 站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,
-	MsgTitle    string      `json:"msgTitle"    orm:"msg_title"    description:""`                                              //
-	MsgContent  string      `json:"msgContent"  orm:"msg_content"  description:""`                                              //
-	CreateTime  *gtime.Time `json:"createTime"  orm:"create_time"  description:""`                                              //
-	UpdateTime  *gtime.Time `json:"updateTime"  orm:"update_time"  description:""`                                              //
+	Id             int         `json:"id"             orm:"id"               description:""`                                              //
+	RuleId         int         `json:"ruleId"         orm:"rule_id"          description:"new_user_send_rule的id"`                         // new_user_send_rule的id
+	SendChannel    int         `json:"sendChannel"    orm:"send_channel"     description:"发送渠道:1-短信 2-站内信 3-邮件"`                          // 发送渠道:1-短信 2-站内信 3-邮件
+	SmsId          int         `json:"smsId"          orm:"sms_id"           description:"短信模板id对应的位置"`                                   // 短信模板id对应的位置
+	SmsVar         string      `json:"smsVar"         orm:"sms_var"          description:"短信模板变量,逗号分割"`                                   // 短信模板变量,逗号分割
+	MsgUrl         string      `json:"msgUrl"         orm:"msg_url"          description:"站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,"` // 站内信跳转地址,各端一样时填一个就行,不一样时按以下顺序逗号分割,pc,安卓,苹果,wx,
+	MsgTitle       string      `json:"msgTitle"       orm:"msg_title"        description:""`                                              //
+	MsgContent     string      `json:"msgContent"     orm:"msg_content"      description:""`                                              //
+	IndustrySmsId  int         `json:"industrySmsId"  orm:"industry_sms_id"  description:"行业短信模板"`                                        // 行业短信模板
+	IndustrySmsVar string      `json:"industrySmsVar" orm:"industry_sms_var" description:"行业短信模板变量"`                                      // 行业短信模板变量
+	CreateTime     *gtime.Time `json:"createTime"     orm:"create_time"      description:""`                                              //
+	UpdateTime     *gtime.Time `json:"updateTime"     orm:"update_time"      description:""`                                              //
+	IndustryMsgUrl string      `json:"industryMsgUrl" orm:"industry_msg_url" description:"有行业的跳转地址"`                                      // 有行业的跳转地址
 }

+ 1 - 0
newuserSend/internal/model/entity/new_user_send_log.go

@@ -17,4 +17,5 @@ type NewUserSendLog struct {
 	State      int         `json:"state"      orm:"state"       description:"发送状态:-1 :取消发送 0:待发送 1:已发送"` // 发送状态:-1 :取消发送 0:待发送 1:已发送
 	CreateTime *gtime.Time `json:"createTime" orm:"create_time" description:""`                          //
 	UpdateTime *gtime.Time `json:"updateTime" orm:"update_time" description:""`                          //
+	Industry   string      `json:"industry"   orm:"industry"    description:"匹配到的行业"`                    // 匹配到的行业
 }

+ 4 - 0
newuserSend/manifest/config/config.yaml

@@ -27,3 +27,7 @@ sms:
   Mark: jy@wz
   ProductId: 0
   rpc: "192.168.3.149:932"
+test:
+  switch: false # 是否仅发送测试手机号短信
+  phone: [ "18238182402" ]
+#industry: {"":} #行业code对应的地址