diff --git a/app/db/dbs_map.go b/app/db/dbs_map.go index cb45884..5acfe9d 100644 --- a/app/db/dbs_map.go +++ b/app/db/dbs_map.go @@ -110,7 +110,7 @@ func GetAllDatabaseDev() *[]model.DbMapping { fmt.Println("cfg.Local is: ", cfg.Local) if cfg.Local { // 本地调试 加快速度 fmt.Println("notice:LOCAL TEST, only masterId:** 99813608 ** available!") - err = Db.Where("deleted_at != ? AND db_master_id=?", 1, 32053480).Find(&m) + err = Db.Where("deleted_at != ? AND db_master_id=?", 1, 31585332).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 521c2aa..0dcca16 100644 --- a/consume/init.go +++ b/consume/init.go @@ -17,49 +17,48 @@ func Init() { // 增加消费任务队列 func initConsumes() { - jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume - jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge - jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv - jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume - jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree - jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal - jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond + //jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge + //jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv + //jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume + //jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree + //jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal + //jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond + //// + //jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal + //jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy + //jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle + //// + //jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder + //jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder // - jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal - jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy - jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle + //jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation + //jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser + // + //jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition + // + //jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial + //jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter + //jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender + //jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans + //jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv + // + //jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay + //jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess + //jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund + //jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond + // + //jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore + // + //jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail + // + //jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume + //jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate + //jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate + // + //jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal + //jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail + //jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward // - jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder - jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder - - jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation - jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser - - jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition - - jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial - jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter - jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender - jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans - jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv - - jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay - jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess - jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund - jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond - - jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore - - jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail - - jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume - jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate - jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate - - jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal - jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail - jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward - //// ////////////////////////////////////// V1 ///////////////////////////////////////////////////// //jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume @@ -75,6 +74,10 @@ func initConsumes() { //jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume //jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume //jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume + + //////////////////////////////////////// oneCircles ///////////////////////////////////////////////////// + jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume + //jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume } func Run() { diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 6b9d7d8..c037600 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -396,7 +396,25 @@ var RabbitMqQueueKeyList = []*MqQueue{ IsPersistent: false, RoutKey: "canal_user_virtual_coin_flow", BindKey: "", - ConsumeFunName: "CanalUserVirtualCcoinFlowConsume", + ConsumeFunName: "CanalUserVirtualCoinFlowConsume", + }, + { + ExchangeName: "one.circles", + Name: "one_circles_sign_in_green_energy", + Type: TopicQueueType, + IsPersistent: false, + RoutKey: "sign_in", + BindKey: "", + ConsumeFunName: "OneCirclesSignInGreenEnergyConsume", + }, + { + ExchangeName: "one.circles", + Name: "one_circles_sign_in_green_energy_copy", + Type: TopicQueueType, + IsPersistent: false, + RoutKey: "sign_in_copy", + BindKey: "", + ConsumeFunName: "OneCirclesSignInCopyGreenEnergyConsume", }, } @@ -444,5 +462,7 @@ const ( ZhiosAcquisitionConditionDevFunName = "ZhiosAcquisitionConditionDev" SupplyCloudChainFenxiaoNewChangeFunName = "SupplyCloudChainFenxiaoNewChangeConsume" MallAddSupplyGoodsFunName = "MallAddSupplyGoodsConsume" - CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCcoinFlowConsume" + CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCoinFlowConsume" + OneCirclesSignInGreenEnergyFunName = "OneCirclesSignInGreenEnergyConsume" + OneCirclesSignInCopyGreenEnergyFunName = "OneCirclesSignInCopyGreenEnergyConsume" ) diff --git a/consume/md/md_one_circles.go b/consume/md/md_one_circles.go new file mode 100644 index 0000000..fa012c5 --- /dev/null +++ b/consume/md/md_one_circles.go @@ -0,0 +1,7 @@ +package md + +type OneCirclesStructForSignIn struct { + MasterId string `json:"master_id"` + Uid int `json:"uid"` + Id int64 `json:"id"` +} diff --git a/consume/one_circles_sign_in_consume.go b/consume/one_circles_sign_in_consume.go new file mode 100644 index 0000000..c0af23c --- /dev/null +++ b/consume/one_circles_sign_in_consume.go @@ -0,0 +1,66 @@ +package consume + +import ( + "applet/app/cfg" + "applet/app/db" + "applet/app/utils/logx" + "applet/consume/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles" + "encoding/json" + "errors" + "fmt" + "github.com/streadway/amqp" +) + +func OneCirclesSignInGreenEnergyConsume(queue md.MqQueue) { + fmt.Println(">>>>>>>>>>>>OneCirclesSignInGreenEnergyConsume>>>>>>>>>>>>") + ch, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + logx.Error(err) + return + } + defer ch.Release() + //1、将自己绑定到交换机上 + ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) + //2、取出数据进行消费 + ch.Qos(1) + delivery := ch.Consume(queue.Name, false) + + one_circles.Init(cfg.RedisAddr) + + var res amqp.Delivery + var ok bool + for { + res, ok = <-delivery + if ok == true { + err = handleOneCirclesSignInGreenEnergy(res.Body) + if err != nil { + fmt.Println("OneCirclesSignInGreenEnergyConsume_ERR:::::", err.Error()) + } + //_ = res.Reject(false) + err = res.Ack(true) + fmt.Println("err ::: ", err) + } else { + panic(errors.New("error getting message")) + } + } + fmt.Println("get msg done") +} + +func handleOneCirclesSignInGreenEnergy(msgData []byte) error { + //1、解析mq中queue的数据结构体 + var msg *md.OneCirclesStructForSignIn + err := json.Unmarshal(msgData, &msg) + if err != nil { + return err + } + + engine := db.DBs[msg.MasterId] + err = one_circles.HandleSettlementSignInGreenEnergy(engine, msg.MasterId, msg.Id, msg.Uid) + fmt.Println("err::::", err) + if err != nil { + return err + } + return nil +} diff --git a/consume/one_circles_sign_in_copy_consume.go b/consume/one_circles_sign_in_copy_consume.go new file mode 100644 index 0000000..ca458a1 --- /dev/null +++ b/consume/one_circles_sign_in_copy_consume.go @@ -0,0 +1,66 @@ +package consume + +import ( + "applet/app/cfg" + "applet/app/db" + "applet/app/utils/logx" + "applet/consume/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles" + "encoding/json" + "errors" + "fmt" + "github.com/streadway/amqp" +) + +func OneCirclesSignInCopyGreenEnergyConsume(queue md.MqQueue) { + fmt.Println(">>>>>>>>>>>>OneCirclesSignInCopyGreenEnergyConsume>>>>>>>>>>>>") + ch, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + logx.Error(err) + return + } + defer ch.Release() + //1、将自己绑定到交换机上 + ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) + //2、取出数据进行消费 + ch.Qos(1) + delivery := ch.Consume(queue.Name, false) + + one_circles.Init(cfg.RedisAddr) + + var res amqp.Delivery + var ok bool + for { + res, ok = <-delivery + if ok == true { + err = handleOneCirclesSignInCopyGreenEnergy(res.Body) + if err != nil { + fmt.Println("OneCirclesSignInCopyGreenEnergyConsume_ERR:::::", err.Error()) + } + //_ = res.Reject(false) + err = res.Ack(true) + fmt.Println("err ::: ", err) + } else { + panic(errors.New("error getting message")) + } + } + fmt.Println("get msg done") +} + +func handleOneCirclesSignInCopyGreenEnergy(msgData []byte) error { + //1、解析mq中queue的数据结构体 + var msg *md.OneCirclesStructForSignIn + err := json.Unmarshal(msgData, &msg) + if err != nil { + return err + } + + engine := db.DBs[msg.MasterId] + err = one_circles.HandleSettlementSignInGreenEnergy(engine, msg.MasterId, msg.Id, msg.Uid) + fmt.Println("err::::", err) + if err != nil { + return err + } + return nil +} diff --git a/etc/cfg.yml b/etc/cfg.yml index 9bee1ce..cdeed99 100644 --- a/etc/cfg.yml +++ b/etc/cfg.yml @@ -29,10 +29,10 @@ wxapplet_filepath: # 连接官网数据库获取db mapping db: - host: 'zhios123.rwlb.rds.aliyuncs.com:3306' + host: '119.23.182.117:3306' name: 'zyos_website' - user: 'canal' - psw: 'canal' + user: 'root' + psw: 'Fnuo123com@' show_log: true max_lifetime: 30 max_open_conns: 100