CoinInstruction.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\common\model;
  3. use think\Cache;
  4. /**
  5. * 平台币说明设置表
  6. * @author Administrator
  7. */
  8. class CoinInstruction extends \think\Model
  9. {
  10. protected $pk = 'id';
  11. protected $table = 'nw_coin_instruction';
  12. protected $dateFormat = false; //时间戳格式不自动转换
  13. const CACHE_KEY = "clearable_coin_instruction";
  14. /**
  15. * 初始化
  16. */
  17. protected static function init()
  18. {
  19. CoinInstruction::afterInsert(function () {
  20. Cache::rm(self::CACHE_KEY);
  21. });
  22. CoinInstruction::afterUpdate(function () {
  23. Cache::rm(self::CACHE_KEY);
  24. });
  25. CoinInstruction::afterWrite(function () {
  26. Cache::rm(self::CACHE_KEY);
  27. });
  28. }
  29. /**
  30. * 获得平台币说明
  31. */
  32. public function getInstruction($name = '')
  33. {
  34. $info = Cache::get(self::CACHE_KEY);
  35. if (empty($info)) {
  36. $info = self::value('content');
  37. if (!empty($info)) {
  38. Cache::set(self::CACHE_KEY, $info);
  39. }
  40. }
  41. return $info;
  42. }
  43. }