Chat.php 771 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\model\kefu;
  3. use think\Model;
  4. class Chat extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'kefu_chat';
  9. public static function getchatid($fromid, $toid)
  10. {
  11. $weid = weid();
  12. $crowd = $fromid . ',' . $toid;
  13. $crowdor = $toid . ',' . $fromid;
  14. $chat = self::where(['weid' => $weid, 'crowd' => $crowd])->find();
  15. if (!empty($chat)) {
  16. return $chat->id;
  17. }
  18. $chat = self::where(['weid' => $weid, 'crowd' => $crowdor])->find();
  19. if (!empty($chat)) {
  20. return $chat->id;
  21. }
  22. $chat = self::create(['weid' => $weid, 'crowd' => $crowd, 'time' => time()]);
  23. return $chat->id;
  24. }
  25. public static function getcrowd($id)
  26. {
  27. $chat = self::where(['id' => $id])->find();
  28. return $chat->crowd;
  29. }
  30. }