Browse Source

订单表增加详细地址字段

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
b82c70ab14
  1. 6
      common/models/ars/Order.php
  2. 92
      common/models/ars/TakingSite.php
  3. 20
      console/migrations/m191203_034004_add_column_address_in_table_ats_order.php

6
common/models/ars/Order.php

@ -34,6 +34,7 @@ use yii\behaviors\TimestampBehavior;
* @property string $discount_decription 折扣说明 * @property string $discount_decription 折扣说明
* @property int $updated_at 更新时间 * @property int $updated_at 更新时间
* @property int $created_at 创建时间 * @property int $created_at 创建时间
* @property string $address 详细地址
*/ */
class Order extends \yii\db\ActiveRecord class Order extends \yii\db\ActiveRecord
{ {
@ -51,9 +52,9 @@ class Order extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id'], 'required'],
[['user_id', 'address'], 'required'],
[['user_id', 'status', 'type', 'goods_count', 'goods_amount', 'shipping_amount', 'shipping_type', 'taking_site', 'pay_type', 'pay_at', 'payment_amount', 'receivables', 'discount_amount'], 'integer'], [['user_id', 'status', 'type', 'goods_count', 'goods_amount', 'shipping_amount', 'shipping_type', 'taking_site', 'pay_type', 'pay_at', 'payment_amount', 'receivables', 'discount_amount'], 'integer'],
[['discount_decription'], 'string'],
[['discount_decription', 'address'], 'string'],
[['order_sn', 'invoice_id'], 'string', 'max' => 64], [['order_sn', 'invoice_id'], 'string', 'max' => 64],
[['consignee', 'phone'], 'string', 'max' => 20], [['consignee', 'phone'], 'string', 'max' => 20],
[['province', 'city', 'area'], 'string', 'max' => 10], [['province', 'city', 'area'], 'string', 'max' => 10],
@ -94,6 +95,7 @@ class Order extends \yii\db\ActiveRecord
'discount_decription' => '折扣说明', 'discount_decription' => '折扣说明',
'updated_at' => '更新时间', 'updated_at' => '更新时间',
'created_at' => '创建时间', 'created_at' => '创建时间',
'address' => '详细地址',
]; ];
} }

92
common/models/ars/TakingSite.php

@ -1,92 +0,0 @@
<?php
namespace common\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
/**
* This is the model class for table "ats_taking_site".
*
* @property int $id
* @property string $name 名称
* @property string $province 省份
* @property string $city 城市
* @property string $area 区域
* @property string $address 地址
* @property int $is_default 是否为默认,1为默认
* @property int $updated_at 更新时间
* @property int $created_at 创建时间
*/
class TakingSite extends \yii\db\ActiveRecord
{
//是否为默认
const IS_DEFAULT_NO = 0; //否
const IS_DEFAULT_YES = 1; //是
public static $isDefault = [
self::IS_DEFAULT_NO => '否',
self::IS_DEFAULT_YES => '是'
];
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'ats_taking_site';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name', 'province', 'city', 'area', 'address'], 'required'],
[['address'], 'string'],
[['is_default'], 'integer'],
[['name'], 'string', 'max' => 120],
[['province', 'city', 'area'], 'string', 'max' => 10],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'name' => '名称',
'province' => '省份',
'city' => '城市',
'area' => '区域',
'address' => '详细地址',
'is_default' => '是否为默认',
'updated_at' => '更新时间',
'created_at' => '创建时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
}

20
console/migrations/m191203_034004_add_column_address_in_table_ats_order.php

@ -0,0 +1,20 @@
<?php
use yii\db\Migration;
/**
* Class m191203_034004_add_column_address_in_table_ats_order
*/
class m191203_034004_add_column_address_in_table_ats_order extends Migration
{
public function up()
{
$this->addColumn('ats_order', 'address', $this->text()->defaultValue('')->notNull()->comment('详细地址'));
}
public function down()
{
$this->dropColumn('ats_order', 'address');
return true;
}
}
Loading…
Cancel
Save