TMC消息为阿里旅行会员等级变更后,会自动推送会员等级变更消息给到商家系统
航旅会员升级,同步酒店,酒店方会根据航旅会员等级和酒店等级返回最高等级。例如航旅会员为f1,酒店返回为v3;航旅升级为f2后,酒店返回仍为v3。例如航旅会员为f1,酒店为v1,升级为f2后,应返回v2。
1.接受消息 实现方式有两种:通过SDK接收消息(推荐)、通过API接收消息
2.解密消息体content,先base64解码,在des解密。解密需要的key值请联系 @简空
static void Main(string[] args) { string app_key = "1021812362"; string app_secret = "sandboxaa000750f78a66c2418ad3982"; TmcClient client = new TmcClient(app_key, app_secret, "default"); client.OnMessage += (s, e) => { try { Console.WriteLine(e.Message.Content);//解密消息体 Console.WriteLine(e.Message.Topic); // 默认不抛出异常则认为消息处理成功,商户可根据自己需求设计后续业务逻辑 } catch (Exception exp) { Console.WriteLine(exp.StackTrace); e.Fail(); // 消息处理失败回滚,服务端需要重发 } }; client.Connect("ws://mc.api.tbsandbox.com/"); Console.Read(); }
{ "old_suggest_level": "V1", //会员原始等级 "partner_id": "qqOiL9UPKqCPLSrJ92tPbg\u003d\u003d", //商家账号userid "old_level": "2", "new_suggest_level": "V2", //建议提升等级 "card_number": "888123456", //会员卡号 "vendor": "taobao", //升级渠道 "user_id": "LU5Kf7E8kGKVjbew2f5Ajw\u003d\u003d", //会员账号userid "new_level": "1" }
//.net版 //解密方法 public static string Decrypt(string str, string strKey) { byte[] bStr = Convert.FromBase64String(str); byte[] key = Encoding.UTF8.GetBytes(strKey); DES des = new DESCryptoServiceProvider(); des.Mode = System.Security.Cryptography.CipherMode.ECB; des.Key = key; des.IV = new byte[8]; byte[] resultBytes = des.CreateDecryptor().TransformFinalBlock(bStr, 0, bStr.Length); return System.Text.Encoding.UTF8.GetString(resultBytes); } //java版 TODO。。。