|
|
@@ -24,6 +24,8 @@ class ReceiveAddressForm extends Model
|
|
|
public $province;
|
|
|
public $city;
|
|
|
public $county;
|
|
|
+ public $lgaName;
|
|
|
+ public $cityName;
|
|
|
public $address;
|
|
|
public $isDefault;
|
|
|
|
|
|
@@ -46,10 +48,10 @@ class ReceiveAddressForm extends Model
|
|
|
public function rules()
|
|
|
{
|
|
|
return [
|
|
|
- [['id', 'consignee', 'mobile', 'province', 'city', 'county', 'address', 'isDefault'], 'trim'],
|
|
|
- [['id', 'consignee', 'mobile', 'province', 'city', 'county', 'address'], 'required'],
|
|
|
+ [['id', 'consignee', 'mobile', 'province', 'lgaName', 'cityName', 'address', 'isDefault'], 'trim'],
|
|
|
+ [['id', 'consignee', 'mobile', 'province', 'lgaName', 'cityName', 'address'], 'required'],
|
|
|
[['mobile'], 'mobile'],
|
|
|
- [['province', 'city', 'county'], 'exist', 'targetClass' => Region::class, 'targetAttribute' => 'REGION_CODE'],
|
|
|
+ [['province'], 'exist', 'targetClass' => Region::class, 'targetAttribute' => 'REGION_CODE'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -59,8 +61,10 @@ class ReceiveAddressForm extends Model
|
|
|
'consignee' => '收货人',
|
|
|
'mobile' => '手机号',
|
|
|
'province' => '省/市',
|
|
|
- 'city' => '市/区',
|
|
|
- 'county' => '区/县',
|
|
|
+// 'city' => '市/区',
|
|
|
+// 'county' => '区/县',
|
|
|
+ 'lgaName' => 'LGA Name',
|
|
|
+ 'cityName' => 'City Name',
|
|
|
'address' => '详细地址',
|
|
|
];
|
|
|
}
|
|
|
@@ -73,8 +77,8 @@ class ReceiveAddressForm extends Model
|
|
|
{
|
|
|
$parentScenarios = parent::scenarios();
|
|
|
$customScenarios = [
|
|
|
- 'userAdd' => ['consignee', 'mobile', 'province', 'city', 'county', 'address', 'isDefault'],
|
|
|
- 'userEdit' => ['id', 'consignee', 'mobile', 'province', 'city', 'county', 'address', 'isDefault'],
|
|
|
+ 'userAdd' => ['consignee', 'mobile', 'province', 'lgaName', 'cityName', 'address', 'isDefault'],
|
|
|
+ 'userEdit' => ['id', 'consignee', 'mobile', 'province', /*'lgaName', 'cityName',*/ 'address', 'isDefault'],
|
|
|
'userIsDefault' => ['id', 'isDefault'],
|
|
|
];
|
|
|
return array_merge($parentScenarios, $customScenarios);
|
|
|
@@ -129,14 +133,15 @@ class ReceiveAddressForm extends Model
|
|
|
if ($this->isDefault) {
|
|
|
ReceiveAddress::updateAll(['IS_DEFAULT' => 0], 'USER_ID=:USER_ID', [':USER_ID'=>\Yii::$app->user->id]);
|
|
|
}
|
|
|
+// print_r($this);exit;
|
|
|
if($this->scenario == 'userAdd'){
|
|
|
$this->_model->USER_ID = \Yii::$app->user->id;
|
|
|
$this->_model->USER_NAME = Info::getUserNameByUserId(\Yii::$app->user->id);
|
|
|
$this->_model->CONSIGNEE = $this->consignee;
|
|
|
$this->_model->MOBILE = $this->mobile;
|
|
|
$this->_model->PROVINCE = $this->province;
|
|
|
- $this->_model->CITY = $this->city;
|
|
|
- $this->_model->COUNTY = $this->county;
|
|
|
+ $this->_model->LGA_NAME = $this->lgaName;
|
|
|
+ $this->_model->CITY_NAME = $this->cityName;
|
|
|
$this->_model->ADDRESS = $this->address;
|
|
|
$this->_model->IS_DEFAULT = $this->isDefault ? 1 : 0;
|
|
|
$this->_model->CREATED_AT = Date::nowTime();
|
|
|
@@ -144,8 +149,8 @@ class ReceiveAddressForm extends Model
|
|
|
$this->_model->CONSIGNEE = $this->consignee;
|
|
|
$this->_model->MOBILE = $this->mobile;
|
|
|
$this->_model->PROVINCE = $this->province;
|
|
|
- $this->_model->CITY = $this->city;
|
|
|
- $this->_model->COUNTY = $this->county;
|
|
|
+ $this->_model->LGA_NAME = $this->lgaName;
|
|
|
+ $this->_model->CITY_NAME = $this->cityName;
|
|
|
$this->_model->ADDRESS = $this->address;
|
|
|
$this->_model->IS_DEFAULT = $this->isDefault ? 1 : 0;
|
|
|
$this->_model->UPDATED_AT = Date::nowTime();
|