User.php 903 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\api\service;
  10. use think\Cache;
  11. class User
  12. {
  13. /**
  14. * 记忆上门自提联系人
  15. * @param $userId
  16. * @param $linkman
  17. * @param $phone
  18. * @return bool
  19. */
  20. public static function setLastExtract($userId, $linkman, $phone)
  21. {
  22. // 缓存时间30天
  23. $expire = 86400 * 30;
  24. return Cache::set("{$userId}_LastExtract", compact('linkman', 'phone'), $expire);
  25. }
  26. /**
  27. * 记忆上门自提联系人
  28. * @param $userId
  29. * @return mixed
  30. */
  31. public static function getLastExtract($userId)
  32. {
  33. if ($lastExtract = Cache::get("{$userId}_LastExtract")) {
  34. return $lastExtract;
  35. }
  36. return ['linkman' => '', 'phone' => ''];
  37. }
  38. }