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.

112 lines
2.8 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_delivery".
  7. *
  8. * @property int $id
  9. * @property int $order_id 订单id
  10. * @property string $shipping_name 货流名称
  11. * @property string $shipping_id 运货单位
  12. * @property int $type 类型
  13. * @property string $goods 商品
  14. * @property int $status 状态
  15. * @property string $decription 描述
  16. * @property int $updated_at 更新时间
  17. * @property int $created_at 创建时间
  18. */
  19. class Delivery extends \yii\db\ActiveRecord
  20. {
  21. const TYPE_SHIPMENT_ALL = 1;
  22. const TYPE_SHIPMENT_PORTION = 2;
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return 'ats_delivery';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['order_id', 'type', 'status'], 'integer'],
  37. [['shipping_id'], 'required'],
  38. [['goods', 'decription'], 'string'],
  39. [['shipping_name'], 'string', 'max' => 50],
  40. [['shipping_id'], 'string', 'max' => 10],
  41. ];
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'id' => 'id',
  50. 'order_id' => '订单id',
  51. 'shipping_name' => '货流名称',
  52. 'shipping_id' => '运货单位',
  53. 'type' => '类型',
  54. 'goods' => '商品',
  55. 'status' => '状态',
  56. 'decription' => '描述',
  57. 'updated_at' => '更新时间',
  58. 'created_at' => '创建时间',
  59. ];
  60. }
  61. /**
  62. * @author linyao
  63. * @email 602604991@qq.com
  64. * @created Nov 8, 2019
  65. *
  66. * 行为存储创建时间和更新时间
  67. */
  68. public function behaviors()
  69. {
  70. return [
  71. [
  72. 'class' => TimestampBehavior::className(),
  73. 'createdAtAttribute' => 'created_at',
  74. 'updatedAtAttribute' => 'updated_at',
  75. 'value' => function() {
  76. return time();
  77. },
  78. ],
  79. ];
  80. }
  81. /**
  82. * @param $column
  83. * @param null $value
  84. * @return bool
  85. * 获取各状态数组
  86. */
  87. public static function dropDown($column, $value = null)
  88. {
  89. $dropDownList = [
  90. 'type' => [
  91. self::TYPE_SHIPMENT_ALL => '全部发货',
  92. self::TYPE_SHIPMENT_PORTION => '部分发货',
  93. ],
  94. ];
  95. //根据具体值显示对应的值
  96. if ($value !== null)
  97. return array_key_exists($column, $dropDownList) ? $dropDownList[$column][$value] : false;
  98. //返回关联数组,用户下拉的filter实现
  99. else
  100. return array_key_exists($column, $dropDownList) ? $dropDownList[$column] : false;
  101. }
  102. }