61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: chatfeed
|
|
* Date: 2022/5/23
|
|
* Time: 7:14 PM
|
|
*/
|
|
|
|
namespace admin\models\forms;
|
|
use common\models\oldDb\DistrictArr;
|
|
use common\models\oldDb\RefundAddress;
|
|
|
|
class RefundAddressEditForm extends RefundAddress
|
|
{
|
|
public $name;
|
|
public $addressId;
|
|
public $address_detail;
|
|
public $mobile;
|
|
public $remark;
|
|
public $id;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['name', 'addressId', 'mobile'], 'required'],
|
|
[['name', 'mobile', 'remark', 'address_detail'], 'string'],
|
|
[['id','addressId'], 'integer'],
|
|
];
|
|
}
|
|
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'name' => '收件人名称',
|
|
'address' => '省市区',
|
|
'address_detail' => '收件人详细地址',
|
|
'mobile' => '收件人手机号',
|
|
'remark' => '备注',
|
|
];
|
|
}
|
|
|
|
public function save($runValidation = true, $attributeNames = null)
|
|
{
|
|
if (!$this->validate()) {
|
|
return ['error'=>$this->getErrors()];
|
|
}
|
|
$addressArr = [];
|
|
$arr = DistrictArr::getArr();
|
|
$area = $arr[$this->addressId];
|
|
|
|
$city = $arr[$area['parent_id']];
|
|
$province = $arr[$city['parent_id']];
|
|
$this->address = json_encode([$province['name'],$city['name'],$area['name']]);
|
|
if (!parent::save($runValidation,$attributeNames)) {
|
|
throw new \Exception('保存失败');
|
|
}else{
|
|
return [];
|
|
}
|
|
}
|
|
}
|