RoutineTemplate.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\admin\model\routine;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. /**
  6. * 小程序模板消息Model
  7. * Class RoutineTemplate
  8. * @package app\admin\model\wechat
  9. */
  10. class RoutineTemplate extends BaseModel
  11. {
  12. /**
  13. * 数据表主键
  14. * @var string
  15. */
  16. protected $pk = 'id';
  17. /**
  18. * 模型名称
  19. * @var string
  20. */
  21. protected $name = 'template_message';
  22. use ModelTrait;
  23. public static function vialdWhere(string $alias = '', int $type = 0)
  24. {
  25. if ($alias) {
  26. $alias .= '.';
  27. }
  28. return self::where($alias . 'type', $type);
  29. }
  30. /**
  31. * 获取系统分页数据 分类
  32. * @param array $where
  33. * @return array
  34. */
  35. public static function systemPage($where = array())
  36. {
  37. $model = self::vialdWhere();
  38. if ($where['name'] !== '') $model = $model->where('name', 'LIKE', "%$where[name]%");
  39. if ($where['status'] !== '') $model = $model->where('status', $where['status']);
  40. return self::page($model, $where);
  41. }
  42. /**
  43. * 根据模版编号获取模版ID
  44. * @param $tempkey
  45. */
  46. public static function getTempid($tempkey)
  47. {
  48. return self::vialdWhere()->where('tempkey', $tempkey)->where('status', 1)->cache(true, 3600)->value('tempid');
  49. }
  50. }