123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace loyalsoft;
- require_once ROOTDIR . '/service_call/pay/Mo/OrderNotice.php';
- require_once ROOTDIR . '/util/tapdb/TapDB_config.php';
- /**
- * tapdb普通事件
- * @author gwang
- */
- class TapDBEvent {
- /**
- * 事件的数据格式的构造函数
- * @param string $uid
- * @param dic $params 属性数组
- */
- public function __construct($uid, $eventName, $params) {
- $this->client_id = TapDB_config::Ins()->gameClientId;
- $this->user_id = $uid;
- $params['channel'] = self::getPlatStr($uid); # 插入下渠道信息
- $this->properties = $params;
- $this->name = str_starts_with($eventName, '#') ? $eventName : "#$eventName";
- }
- public $name = ""; // 必需, 事件名,一般为 "#xxx"
- public $type = "track"; // 必须, 固定为 "track"
- public $client_id; // 必需。注意 ClientID 需要被替换成游戏的 ClientID
- public $user_id; // 必需。用户ID。
- public $properties; // 属性值
- /**
- * 获得用户的平台字符串
- * @return string
- */
- static function getPlatStr($uid) {
- if (strrpos($uid, '_') > 0) {
- return substr($uid, strrpos($uid, '_') + 1); # 提取平台字符串
- } else {
- if (strlen($uid) == 32) {
- return "loyal";
- } else {
- return "taptap";
- }
- }
- //PS. substr() 函数返回字符串的一部分 strrpos() 函数查找字符串在另一字符串中最后一次出现的位置。
- }
- }
- /**
- * tapdb预定义事件
- * @author gwang
- */
- class TapDBPreEvent {
- /**
- * 事件的数据格式的构造函数
- * @param string $uid
- * @param dic $params 属性数组
- */
- public function __construct($uid, $eventName, $params) {
- $this->client_id = TapDB_config::Ins()->gameClientId;
- $this->user_id = $uid;
- $params['channel'] = self::getPlatStr($uid); # 插入下渠道信息
- $this->properties = $params;
- $this->name = $eventName; # 预定以事件名称一般不带#
- }
- public $name = ""; // 必需, 事件名,一般为 "#xxx"
- public $type = "track"; // 必须, 固定为 "track"
- public $client_id; // 必需。注意 ClientID 需要被替换成游戏的 ClientID
- public $user_id; // 必需。用户ID。
- public $properties; // 属性值
- public $device_id = "-"; // 设备id, 服务端上报可以传一个固定值。
- /**
- * 获得用户的平台字符串
- * @return string
- */
- static function getPlatStr($uid) {
- if (strrpos($uid, '_') > 0) {
- return substr($uid, strrpos($uid, '_') + 1); # 提取平台字符串
- } else {
- if (strlen($uid) == 32) {
- return "loyal";
- } else {
- return "taptap";
- }
- }
- //PS. substr() 函数返回字符串的一部分 strrpos() 函数查找字符串在另一字符串中最后一次出现的位置。
- }
- }
|