ShippingTemplates.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\models\system;
  3. use crmeb\traits\ModelTrait;
  4. use crmeb\basic\BaseModel;
  5. /**
  6. * Class ShippingTemplates
  7. * @package app\models\system
  8. */
  9. class ShippingTemplates extends BaseModel
  10. {
  11. /**
  12. * 数据表主键
  13. * @var string
  14. */
  15. protected $pk = 'id';
  16. /**
  17. * 模型名称
  18. * @var string
  19. */
  20. protected $name = 'shipping_templates';
  21. use ModelTrait;
  22. public static function merSet($mer_id)
  23. {
  24. return $mer_id ? self::where('mer_id', $mer_id) : new self;
  25. }
  26. public function getTypeAttr($value)
  27. {
  28. $status = [1 => '按件数', 2 => '按重量', 3 => '按体积'];
  29. return $status[$value];
  30. }
  31. public function getAppointAttr($value)
  32. {
  33. $status = [1 => '开启', 0 => '关闭'];
  34. return $status[$value];
  35. }
  36. public function getAddTimeAttr($value)
  37. {
  38. $value = date('Y-m-d H:i:s', $value);
  39. return $value;
  40. }
  41. /**
  42. * 运费模板列表
  43. * @param array $where
  44. * @return array
  45. */
  46. public static function getList($where = [])
  47. {
  48. $model = new self();
  49. if (isset($where['mer_id']) && $where['mer_id'] != '') $model = $model->where('mer_id', $where['mer_id']);
  50. if (isset($where['name']) && $where['name'] != '') $model = $model->where('name', 'like', "%$where[name]%");
  51. $data = $model->page($where['page'], $where['limit'])->order('sort', 'desc')->select()->toArray();
  52. $count = $model->count();
  53. return compact('count', 'data');
  54. }
  55. }