Activity.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\admin\model;
  3. use support\Db;
  4. use support\Model;
  5. /**
  6. * 套餐项目模型
  7. * Class Users
  8. * @packagegoods app\admin\model
  9. */
  10. class Activity extends Model
  11. {
  12. const ROLE_STATUS = 1;
  13. const IS_DEL_YES = 1;
  14. const IS_DEL_NO = 0;
  15. const GOODS_IS_SHOW = [
  16. self::IS_DEL_YES => '已删除',
  17. self::IS_DEL_NO => '未删除'
  18. ];
  19. /**
  20. * The table associated with the model.
  21. *
  22. * @var string
  23. */
  24. protected $table = 'activity';
  25. public $timestamps = false;
  26. /**
  27. * Notes:获取活动列表
  28. * @param string $keywords
  29. * @param int $page
  30. * @param int $limit
  31. * @return array
  32. * User: YCP
  33. * Date: 2023/2/23
  34. */
  35. public static function getActivityList(int $page, int $limit, string $keywords)
  36. {
  37. $list = static::select('*')
  38. ->where(['config_is_del'=>static::IS_DEL_NO])
  39. ->when($keywords != '', function ($query) use ($keywords){
  40. $query->where('config_name', 'like', '%' . $keywords . '%');
  41. })
  42. ->orderBy('config_create_time','DESC')
  43. ->forPage($page, $limit)
  44. ->get();
  45. foreach ($list as &$value) {
  46. $value['activity_url'] = "https://service.wanyuewellness.cn/h5/#/?act=".$value['config_id'];
  47. }
  48. $count = static::where(['config_is_del'=>static::IS_DEL_NO])
  49. ->when($keywords != '', function ($query) use ($keywords){
  50. $query->where('config_name', 'like', '%' . $keywords . '%');
  51. })
  52. ->count();
  53. return [$list, $count];
  54. }
  55. //时间格式
  56. public function getConfigCreateTimeAttribute($value)
  57. {
  58. return date('Y-m-d H:i:s', $value);
  59. }
  60. }