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.

97 lines
2.5 KiB

  1. <?php
  2. namespace common\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 $calculation 计算方式
  14. * @property int $basic_price 基本运费
  15. * @property int $basic_amount 基本数量
  16. * @property int $extra_price 续重运费
  17. * @property int $extra_amount 续重运费
  18. * @property int $updated_at 更新时间
  19. * @property int $created_at 创建时间
  20. */
  21. class ExpressTemplate extends \yii\db\ActiveRecord
  22. {
  23. //计算方式calculation
  24. const CALCULATION_WEIGHT = 1; //按重量
  25. const CALCULATION_NUMBER = 2; //按件数
  26. public static $calculation = [
  27. self::CALCULATION_WEIGHT => '按重量',
  28. self::CALCULATION_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', 'basic_price', 'basic_amount', 'extra_price', 'extra_amount'], 'integer'],
  46. [['name'], 'string', 'max' => 255],
  47. ];
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function attributeLabels()
  53. {
  54. return [
  55. 'id' => 'id',
  56. 'name' => '名称',
  57. 'province' => '省份',
  58. 'city' => '城市',
  59. 'area' => '区域',
  60. 'calculation' => '计算方式',
  61. 'basic_price' => '基本运费',
  62. 'basic_amount' => '基本数量',
  63. 'extra_price' => '续重运费',
  64. 'extra_amount' => '续重运费',
  65. 'updated_at' => '更新时间',
  66. 'created_at' => '创建时间',
  67. ];
  68. }
  69. /**
  70. * @author linyao
  71. * @email 602604991@qq.com
  72. * @created Nov 8, 2019
  73. *
  74. * 行为存储创建时间和更新时间
  75. */
  76. public function behaviors()
  77. {
  78. return [
  79. [
  80. 'class' => TimestampBehavior::className(),
  81. 'createdAtAttribute' => 'created_at',
  82. 'updatedAtAttribute' => 'updated_at',
  83. 'value' => function() {
  84. return time();
  85. },
  86. ],
  87. ];
  88. }
  89. }