RankDict.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的多应用管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace addon\mall\app\dict\goods;
  12. class RankDict
  13. {
  14. // 排行周期 day=天,week=周,month=月, quarter=季度
  15. const DAY = 'day';
  16. const WEEK = 'week';
  17. const MONTH = 'month';
  18. const QUARTER = 'quarter';
  19. // 来源类型 all=全部,goods=指定商品,category=指定分类,brand=指定品牌, label=指定标签
  20. const ALL = 'all';
  21. const GOODS = 'goods';
  22. const CATEGORY = 'category';
  23. const BRAND = 'brand';
  24. const LABEL = 'label';
  25. // 排序规则 sale=按照销量,collect=按收藏数,evaluate=按评价数, access=按照浏览量
  26. const SALE = 'sale';
  27. const COLLECT = 'collect';
  28. const EVALUATE = 'evaluate';
  29. const ACCESS = 'access';
  30. // 状态(0:关闭,1:开启)
  31. const ON = 1;
  32. const OFF = 0;
  33. /**
  34. * 排行周期
  35. * @param $type
  36. * @return array|mixed|string
  37. */
  38. public static function getRankType($type = '')
  39. {
  40. $data = [
  41. self::DAY => get_lang('dict_mall_goods_rank_rank_type.day'), // 天
  42. self::WEEK => get_lang('dict_mall_goods_rank_rank_type.week'), // 周
  43. self::MONTH => get_lang('dict_mall_goods_rank_rank_type.month'), // 月
  44. self::QUARTER => get_lang('dict_mall_goods_rank_rank_type.quarter'), // 季度
  45. ];
  46. if (!$type) {
  47. return $data;
  48. }
  49. return $data[ $type ] ?? '';
  50. }
  51. /**
  52. * 来源类型
  53. * @param $type
  54. * @return array|mixed|string
  55. */
  56. public static function getGoodsSource($type = '')
  57. {
  58. $data = [
  59. self::ALL => get_lang('dict_mall_goods_rank_goods_source.all'), // 全部
  60. // self::GOODS => get_lang('dict_mall_goods_rank_goods_source.goods'), // 指定商品
  61. self::CATEGORY => get_lang('dict_mall_goods_rank_goods_source.category'), // 指定分类
  62. self::BRAND => get_lang('dict_mall_goods_rank_goods_source.brand'), // 指定品牌
  63. self::LABEL => get_lang('dict_mall_goods_rank_goods_source.label'), // 指定标签
  64. ];
  65. if (!$type) {
  66. return $data;
  67. }
  68. return $data[ $type ] ?? '';
  69. }
  70. /**
  71. * 排序规则
  72. * @param $type
  73. * @return array|mixed|string
  74. */
  75. public static function getRuleType($type = '')
  76. {
  77. $data = [
  78. self::SALE => get_lang('dict_mall_goods_rank_rule_type.sale'), // 按销量
  79. self::COLLECT => get_lang('dict_mall_goods_rank_rule_type.collect'), // 按收藏数
  80. self::EVALUATE => get_lang('dict_mall_goods_rank_rule_type.evaluate'), // 按评价数
  81. self::ACCESS => get_lang('dict_mall_goods_rank_rule_type.access'), // 按浏览量
  82. ];
  83. if (!$type) {
  84. return $data;
  85. }
  86. return $data[ $type ] ?? '';
  87. }
  88. }