初始化仓库
This commit is contained in:
62
admin/models/forms/RefundAddressEditForm.php
Normal file
62
admin/models/forms/RefundAddressEditForm.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: chatfeed
|
||||
* Date: 2022/5/23
|
||||
* Time: 7:14 PM
|
||||
*/
|
||||
|
||||
namespace admin\models\forms;
|
||||
use admin\exceptions\ApiException;
|
||||
use common\models\DistrictArr;
|
||||
use common\models\RefundAddress;
|
||||
use yii\base\Model;
|
||||
|
||||
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 [];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user