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.

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