You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.5 KiB

  1. <?php
  2. namespace backend\modules\shop\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "ats_express_template".
  7. *
  8. * @property int $id
  9. * @property string $name 名称
  10. * @property string $province 省份
  11. * @property string $city 城市
  12. * @property string $area 区域
  13. * @property int $extra_price 续重运费
  14. * @property int $updated_at 更新时间
  15. * @property int $created_at 创建时间
  16. * @property int $basic_price 基本运费
  17. * @property int $basic_count 基本数量
  18. * @property int $extra_count 续重数量
  19. * @property int $calculation_type 计算方式
  20. */
  21. class ExpressTemplate extends \yii\db\ActiveRecord
  22. {
  23. //计算方式calculation_type
  24. const CALCULATION_TYPE_WEIGHT = 1; //按重量
  25. const CALCULATION_TYPE_NUMBER = 2; //按件数
  26. public static $calculationType = [
  27. self::CALCULATION_TYPE_WEIGHT => '按重量',
  28. self::CALCULATION_TYPE_NUMBER => '按件数'
  29. ];
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public static function tableName()
  34. {
  35. return 'ats_express_template';
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['name'], 'required'],
  44. [['province', 'city', 'area'], 'string'],
  45. [['calculation_type'], 'integer'],
  46. [['name'], 'string', 'max' => 255],
  47. [['extra_price', 'basic_price', 'basic_count', 'extra_count'], 'safe']
  48. ];
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'id' => 'id',
  57. 'name' => '名称',
  58. 'province' => '省份',
  59. 'city' => '城市',
  60. 'area' => '区域',
  61. 'extra_price' => '续重运费',
  62. 'updated_at' => '更新时间',
  63. 'created_at' => '创建时间',
  64. 'basic_price' => '基本运费',
  65. 'basic_count' => '基本数量',
  66. 'extra_count' => '续重数量',
  67. 'calculation_type' => '计算方式',
  68. ];
  69. }
  70. /**
  71. * @author linyao
  72. * @email 602604991@qq.com
  73. * @created Nov 8, 2019
  74. *
  75. * 行为存储创建时间和更新时间
  76. */
  77. public function behaviors()
  78. {
  79. return [
  80. [
  81. 'class' => TimestampBehavior::className(),
  82. 'createdAtAttribute' => 'created_at',
  83. 'updatedAtAttribute' => 'updated_at',
  84. 'value' => function() {
  85. return time();
  86. },
  87. ],
  88. ];
  89. }
  90. }