55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\db\ActiveRecord;
|
|
|
|
class RefundAddress extends \common\modelsgii\RefundAddress
|
|
{
|
|
public $address_id;
|
|
|
|
public $full_address;
|
|
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
[
|
|
'class' => TimestampBehavior::class,
|
|
'attributes' => [
|
|
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
|
|
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['mall_id','address','address_detail','address_id'], 'required'],
|
|
[['mall_id', 'created_at', 'updated_at', 'is_delete'], 'integer'],
|
|
[['name'], 'string', 'max' => 65],
|
|
[['address', 'address_detail', 'mobile', 'remark'], 'string', 'max' => 255],
|
|
];
|
|
}
|
|
|
|
public function beforeValidate()
|
|
{
|
|
$arr = DistrictArr::getArr();
|
|
$area = $arr[$this->address_id];
|
|
$city = $arr[$area['parent_id']];
|
|
$province = $arr[$city['parent_id']];
|
|
$this->address = json_encode([[$province['id'],$province['name']],[$city['id'],$city['name']],[$area['id'],$area['name']]]);
|
|
return parent::beforeValidate(); // TODO: Change the autogenerated stub
|
|
}
|
|
public function afterFind()
|
|
{
|
|
parent::afterFind(); // TODO: Change the autogenerated stub
|
|
if($this->address){
|
|
$address = json_decode($this->address);
|
|
$this->full_address = $address[0][1].$address[1][1].$address[2][1].$this->address_detail;
|
|
$this->address_id =$address[2][0];
|
|
}
|
|
}
|
|
}
|