ソースを参照

Merge branch 'fixbug/sop' into debug

* fixbug/sop:
  修复阶段转发变量问题
  临时提交
boweniac 3 ヶ月 前
コミット
81e5c6b068

+ 0 - 3
ent/schema/label_relationship.go

@@ -1,8 +1,6 @@
 package schema
 
 import (
-	"wechat-api/ent/schema/localmixin"
-
 	"entgo.io/ent"
 	"entgo.io/ent/dialect/entsql"
 	"entgo.io/ent/schema"
@@ -34,7 +32,6 @@ func (LabelRelationship) Mixin() []ent.Mixin {
 	return []ent.Mixin{
 		mixins.IDMixin{},
 		mixins.StatusMixin{},
-		localmixin.SoftDeleteMixin{},
 	}
 }
 

+ 3 - 3
internal/logic/Wxhook/get_friends_and_groups_logic.go

@@ -55,13 +55,13 @@ type GetWechatFriendListResp struct {
 }
 
 func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *types.BaseMsgResp, err error) {
-	organizationId := l.ctx.Value("organizationId").(uint64)
+	//organizationId := l.ctx.Value("organizationId").(uint64)
 	wxInfo, err := l.svcCtx.DB.Wx.Get(l.ctx, req.Id)
-	if err != nil {
+	if err != nil || wxInfo == nil {
 		l.Error("查询微信信息失败", err)
 		return
 	}
-
+	organizationId := wxInfo.OrganizationID
 	if wxInfo.ServerID > 0 {
 		//云托管版本
 		serverInfo, err := l.svcCtx.DB.Server.Get(l.ctx, wxInfo.ServerID)

+ 12 - 1
internal/logic/sop_task/publish_sop_task_logic.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 	"regexp"
+	"strings"
 	"wechat-api/ent"
 	"wechat-api/ent/contact"
 	"wechat-api/ent/custom_types"
@@ -156,13 +157,14 @@ func (l *PublishSopTaskLogic) PublishSopTask(req *types.IDReq) (resp *types.Base
 										if message.Meta != nil {
 											meta.Filename = message.Meta.Filename
 										}
+										content := varReplace(message.Content, c)
 										_, err = l.svcCtx.DB.MessageRecords.Create().
 											SetBotWxid(c.WxWxid).
 											SetContactID(0).
 											SetContactType(0).
 											SetContactWxid(forwardWxid).
 											SetContentType(message.Type).
-											SetContent(message.Content).
+											SetContent(content).
 											SetMeta(meta).
 											SetSourceType(sourceType).
 											SetSourceID(stage.ID).
@@ -431,3 +433,12 @@ func splitString(input string) []string {
 	// Split the input string based on the pattern
 	return re.Split(input, -1)
 }
+
+func varReplace(s string, contactInfo *ent.Contact) string {
+	nickname := ""
+	if contactInfo != nil {
+		nickname = contactInfo.Nickname
+	}
+	s = strings.Replace(s, "${nickname}", nickname, -1)
+	return s
+}