TiktokService.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\service;
  3. use app\common\library\Tiktok;
  4. use think\Config;
  5. class TiktokService
  6. {
  7. public function push($action, $userid, $gameid, $channelId, $extend)
  8. {
  9. if (!($extend['Oaid'] || $extend['Idfa'] || $extend['Androidid'] || $extend['Imei']) && $action == 'tiktok.active_register') {
  10. // log_message('TiktokService:push'.json_encode($extend), 'info', LOG_PATH . '../tiktok/');
  11. return false;
  12. }
  13. if (!$game = model('TiktokPush')->alias('a')->cache('TiktokService:push:channel:' . $channelId, 300)
  14. ->join('cy_gameinfo b', 'a.game_id=b.game_id')
  15. ->where(['a.game_id' => $gameid, 'a.channel_id' => $channelId])->field('a.id,b.platform')->find()) {
  16. // log_message('TiktokService:push:game_id'.$gameid.'channel_id:'.$channelId.'不需要推送', 'info', LOG_PATH . '../tiktok/');
  17. return false;
  18. }
  19. $tiktok = new Tiktok();
  20. $extend = [
  21. 'Oaid' => $extend['Oaid'],
  22. 'Gameid' => $gameid,
  23. 'Idfa' => $extend['Idfa'],
  24. 'Androidid' => $extend['Androidid'],
  25. 'Imei' => $extend['Imei'],
  26. 'ChannelId' => $channelId,
  27. 'Platform' => $game['platform'] == 1 ? 'ios' : 'android',
  28. 'PayAmount' => $extend['PayAmount'] * 100,
  29. 'Ip' => $extend['Ip'],
  30. ];
  31. return $tiktok->addTask($action, $userid, $extend);
  32. }
  33. }