From b345060c68506eb85adb69a96da86a0b16727cb3 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 29 Jul 2024 20:17:36 +0800 Subject: [PATCH] update --- app/db/dbs_map.go | 2 +- consume/init.go | 16 +-- super_cloud_issuance/enum/enum_api.go | 3 + super_cloud_issuance/md/md_api.go | 7 ++ .../svc/svc_cloud_issuance.go | 11 ++ .../svc/svc_deal_call_back.go | 117 ++++++++++++++++++ 6 files changed, 147 insertions(+), 9 deletions(-) diff --git a/app/db/dbs_map.go b/app/db/dbs_map.go index 07d12c9..c393fcf 100644 --- a/app/db/dbs_map.go +++ b/app/db/dbs_map.go @@ -111,7 +111,7 @@ func GetAllDatabaseDev() *[]model.DbMapping { if cfg.Local { // 本地调试 加快速度 fmt.Println("notice:LOCAL TEST, only masterId:** 123456 ** available!") err = Db.Where("deleted_at != ? AND is_dev = '1' AND db_master_id= ?", 1, 123456). - Or("db_master_id = ?", 31585332).Find(&m) + Or("db_master_id = ?", 12293740).Find(&m) } else { err = Db.Where("deleted_at != ? AND is_dev = '1' ", 1).Find(&m) } diff --git a/consume/init.go b/consume/init.go index ccb93dd..61b0789 100644 --- a/consume/init.go +++ b/consume/init.go @@ -86,12 +86,12 @@ func initConsumes() { //jobs[consumeMd.CanalB2cOrderForNumericalStatementConsumeFunName] = CanalB2cOrderForNumericalStatementConsume //////////////////////////////////////// oneCircles-v1 ///////////////////////////////////////////////////// - jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume - jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume - jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume - jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume - jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume - jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume + //jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume + //jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume + //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume + //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume + //jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume + //jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume //////////////////////////////////////// oneCircles-v2 ///////////////////////////////////////////////////// //jobs[consumeMd.OneCirclesDealUserCoinConsumeFunName] = OneCirclesDealUserCoinConsume @@ -108,8 +108,8 @@ func initConsumes() { //jobs[consumeMd.InstallmentPaymentAutoRepaidConsumeFunName] = InstallmentPaymentAutoRepaidConsume //分期付 - 自动扣款 ////////////////////////////////////// SuperCloudIssuance ///////////////////////////////////////////////////// - //jobs[consumeMd.SuperCloudIssuanceMsgCallBackFunName] = SuperCloudIssuanceMsgCallBackConsume - //jobs[consumeMd.SuperCloudIssuanceAsyncMLoginFunName] = SuperCloudIssuanceAsyncMLoginConsume + jobs[consumeMd.SuperCloudIssuanceMsgCallBackFunName] = SuperCloudIssuanceMsgCallBackConsume + jobs[consumeMd.SuperCloudIssuanceAsyncMLoginFunName] = SuperCloudIssuanceAsyncMLoginConsume ////////////////////////////////////// DMS ///////////////////////////////////////////////////// //jobs[consumeMd.CanalGimMessageConsumeFunName] = CanalGimMessageConsume diff --git a/super_cloud_issuance/enum/enum_api.go b/super_cloud_issuance/enum/enum_api.go index e0c1a72..7b9c623 100644 --- a/super_cloud_issuance/enum/enum_api.go +++ b/super_cloud_issuance/enum/enum_api.go @@ -22,6 +22,7 @@ const ( RobotMacRepeatCircleMethodName = "itaoke.robot.macrepeat.circle" RobotMacSendAppMethodName = "itaoke.robot.macsend.app" RobotMacSendCircleMethodName = "itaoke.robot.macsend.circle" + RobotMacSendEmojiMethodName = "itaoke.robot.macsend.emoji" ) func (gt CloudIssuanceMethodName) String() string { @@ -64,6 +65,8 @@ func (gt CloudIssuanceMethodName) String() string { return "转发小程序等XML" case RobotMacSendCircleMethodName: return "发送朋友圈" + case RobotMacSendEmojiMethodName: + return "转发emoji表情" default: return "未知" } diff --git a/super_cloud_issuance/md/md_api.go b/super_cloud_issuance/md/md_api.go index 409461d..ee12213 100644 --- a/super_cloud_issuance/md/md_api.go +++ b/super_cloud_issuance/md/md_api.go @@ -142,6 +142,13 @@ type RobotMacSendRecvVideoRequest struct { Content string `json:"content"` //消息xml内容 } +type RobotMacSendEmojiRequest struct { + RobotId int `json:"robot_id"` //机器人id + WxId string `json:"wx_id"` //发送微信好友/群id。一般wxid_开头 + ImageMd5 string `json:"image_md5"` //取回调中xml中md5字段值 + ImageSize string `json:"image_size"` //取回调中xml中len字段值 +} + type RobotMacSendCircleRequest struct { RobotId int `json:"robot_id"` //机器人id PicUrl string `json:"pic_url"` //图片url,多个请用;分隔 diff --git a/super_cloud_issuance/svc/svc_cloud_issuance.go b/super_cloud_issuance/svc/svc_cloud_issuance.go index 3c4a3e0..5d36e3e 100644 --- a/super_cloud_issuance/svc/svc_cloud_issuance.go +++ b/super_cloud_issuance/svc/svc_cloud_issuance.go @@ -324,6 +324,17 @@ func (svcCloudIssuance *CloudIssuanceService) RobotMacSendRecvVideo(args md.Robo return } +func (svcCloudIssuance *CloudIssuanceService) RobotMacSendEmoji(args md.RobotMacSendEmojiRequest) (err error) { // 发送文本消息 + url := super_cloud_issuance.HttpBuild(svcCloudIssuance.RequestMethodName, svcCloudIssuance.RequestClientIp, map[string]string{ + "robot_id": strconv.Itoa(args.RobotId), + "wx_id": args.WxId, + "image_md5": args.ImageMd5, + "image_size": args.ImageSize, + }) + _, err = svcCloudIssuance.SendPost(url, args) + return +} + func (svcCloudIssuance *CloudIssuanceService) RobotMacSendCircle(args md.RobotMacSendCircleRequest) (err error) { // 下线机器人 url := super_cloud_issuance.HttpBuild(svcCloudIssuance.RequestMethodName, svcCloudIssuance.RequestClientIp, map[string]string{ "robot_id": strconv.Itoa(args.RobotId), diff --git a/super_cloud_issuance/svc/svc_deal_call_back.go b/super_cloud_issuance/svc/svc_deal_call_back.go index b1589cc..08a3ad4 100644 --- a/super_cloud_issuance/svc/svc_deal_call_back.go +++ b/super_cloud_issuance/svc/svc_deal_call_back.go @@ -15,6 +15,7 @@ import ( "fmt" "github.com/gin-gonic/gin" "math/rand" + "regexp" "time" ) @@ -140,6 +141,60 @@ func (dealSuperCloudIssuanceCallBackService *DealSuperCloudIssuanceCallBackServi } } break + case 20: + if req.Data.MsgType == "47" { + //TODO::表情 + dealSuperCloudIssuanceCallBackService.DealSourceGroupMessage(req.Data.FromGroup, req) + + utils.FilePutContents("DealSourceGroupMessage_Tmp", utils.SerializeStr(req)) + //解析 content 中的xml 数据 + // 编译正则表达式 + // 注意:这里假设md5和len属性只会出现一次,并且格式如上所述 + md5Regex := regexp.MustCompile(`md5="([^"]*)"`) + lenRegex := regexp.MustCompile(`len\s*=\s*"([^"]*)"`) + // 查找md5 + md5Matches := md5Regex.FindStringSubmatch(req.Data.Content) + if len(md5Matches) > 1 { + fmt.Println("md5:", md5Matches[1]) + } else { + fmt.Println("md5 not found") + return + } + // 查找len + lenMatches := lenRegex.FindStringSubmatch(req.Data.Content) + if len(lenMatches) > 1 { + fmt.Println("len:", lenMatches[1]) + } else { + fmt.Println("len not found") + return + } + + bindId := dealSuperCloudIssuanceCallBackService.IsNeedDealGroupMessage(req.Data.FromGroup, req.Data.FromUser, req.RobotId) + if bindId == 0 { + return + } + //3、查询需转发的群 + superCloudIssuanceUserRobotBindFollowGroupDb := implement.NewSuperCloudIssuanceUserRobotBindFollowGroupDb(engine) + cloudIssuanceUserRobotBindFollowGroups, err := superCloudIssuanceUserRobotBindFollowGroupDb.GetCloudIssuanceUserRobotBindFollowGroupByBindId(bindId) + if err != nil { + fmt.Println("DealCallBack_err::::", err.Error()) + return + } + for _, cloudIssuanceUserRobotBindFollowGroup := range cloudIssuanceUserRobotBindFollowGroups { + cloudIssuanceService.Set(nil, enum.RobotMacSendEmojiMethodName, "127.0.0.1") + err = cloudIssuanceService.RobotMacSendEmoji(md.RobotMacSendEmojiRequest{ + RobotId: req.RobotId, + WxId: cloudIssuanceUserRobotBindFollowGroup.FollowChatRoomId, + ImageMd5: md5Matches[1], + ImageSize: lenMatches[1], + }) + if err != nil { + fmt.Println("DealCallBack_err::::", err.Error()) + return + } + } + } + break } } } @@ -351,6 +406,68 @@ func (dealSuperCloudIssuanceCallBackService *DealSuperCloudIssuanceCallBackServi } } break + case 20: + if req.Data.MsgType == "47" { + //TODO::表情 + //解析 content 中的xml 数据 + // 编译正则表达式 + // 注意:这里假设md5和len属性只会出现一次,并且格式如上所述 + md5Regex := regexp.MustCompile(`md5="([^"]*)"`) + lenRegex := regexp.MustCompile(`len\s*=\s*"([^"]*)"`) + // 查找md5 + md5Matches := md5Regex.FindStringSubmatch(req.Data.Content) + if len(md5Matches) > 1 { + fmt.Println("md5:", md5Matches[1]) + } else { + fmt.Println("md5 not found") + return + } + // 查找len + lenMatches := lenRegex.FindStringSubmatch(req.Data.Content) + if len(lenMatches) > 1 { + fmt.Println("len:", lenMatches[1]) + } else { + fmt.Println("len not found") + return + } + //3、查询需转发的群 + err = engine.Where("activate_group_id =?", superCloudIssuanceUserRobotBindSource.ActivateGroupId).Find(&superCloudIssuanceUserRobotBindSourceFollowGroups) + if err != nil { + fmt.Println("DealSourceGroupMessage_Err:::::", err.Error()) + return err + } + for _, superCloudIssuanceUserRobotBindSourceFollowGroup := range superCloudIssuanceUserRobotBindSourceFollowGroups { + group, err6 := superCloudIssuanceUserRobotWithActivateGroupDb.GetSuperCloudIssuanceUserRobotWithActivateGroup(superCloudIssuanceUserRobotBindSourceFollowGroup.FollowActivateGroupId) + if err6 != nil { + fmt.Println("DealSourceGroupMessage_Err:::::", err6.Error()) + return err + } + if group == nil { + fmt.Println("DealSourceGroupMessage_Err:::::", "未查询到激活群记录") + return errors.New("未查询到激活群记录") + } + if group.State != 1 { + continue + } + + superCloudIssuanceUserRobotDb := implement.NewSuperCloudIssuanceUserRobotDb(engine, superCloudIssuanceUserRobotBindSourceFollowGroup.Uid, dealSuperCloudIssuanceCallBackService.Context.GetString("mid")) + robot, _ := superCloudIssuanceUserRobotDb.GetSuperCloudIssuanceUserRobot() + if robot != nil { + cloudIssuanceService.Set(nil, enum.RobotMacSendEmojiMethodName, "127.0.0.1") + err5 := cloudIssuanceService.RobotMacSendEmoji(md.RobotMacSendEmojiRequest{ + RobotId: robot.RobotId, + WxId: superCloudIssuanceUserRobotBindSourceFollowGroup.FollowChatRoomId, + ImageMd5: md5Matches[1], + ImageSize: lenMatches[1], + }) + if err5 != nil { + fmt.Println("DealCallBack_err::::", err5.Error()) + return + } + } + } + } + break } }