Stat.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\model\goods;
  12. use app\dict\sys\FileDict;
  13. use core\base\BaseModel;
  14. /**
  15. * 商品数据统计模型
  16. * Class Label
  17. * @package addon\mall\app\model\goods\Stat
  18. */
  19. class Stat extends BaseModel
  20. {
  21. protected $autoWriteTimestamp = false;
  22. /**
  23. * 数据表主键
  24. * @var string
  25. */
  26. protected $pk = 'id';
  27. /**
  28. * 模型名称
  29. * @var string
  30. */
  31. protected $name = 'mall_goods_stat';
  32. //类型
  33. protected $type = [
  34. 'date_time' => 'timestamp',
  35. ];
  36. /**
  37. * 关联默认商品
  38. * @return \think\model\relation\HasOne
  39. */
  40. public function goods()
  41. {
  42. return $this->hasOne(Goods::class, 'goods_id', 'goods_id');
  43. }
  44. /**
  45. * 获取封面缩略图(小)
  46. */
  47. public function getGoodsCoverThumbSmallAttr($value, $data)
  48. {
  49. if (isset($data[ 'goods_cover' ]) && $data[ 'goods_cover' ] != '') {
  50. return get_thumb_images($data[ 'site_id' ], $data[ 'goods_cover' ], FileDict::SMALL);
  51. }
  52. return [];
  53. }
  54. }