Bladeren bron

ng收货地址格式,区划等修改

theo 3 jaren geleden
bovenliggende
commit
2647a385d7

+ 1 - 1
common/helpers/Validator.php

@@ -26,7 +26,7 @@ class Validator extends \yii\validators\Validator {
         'chDate'	    =>	["#^\d{4}([/-])([0][0-9]|[1][0-2])\\1([0-2][0-9]|[3][0-1])$#", '必须为日期格式'],
         'chMonth'       =>  ["#^\d{4}([/-])([0][0-9]|[1][0-2]|[0-9])$#", '必须为年月格式'],
         'phone'			=>	["#^\d{3}-\d{8}|\d{4}-\d{7}|\d{4}-\d{8}$#", '必须为电话格式'],
-        'mobile'        =>	["|^1[2-9]\d{9}$|", '格式输入不正确'],
+        'mobile'        =>	["|^0[7-9]\d{9}$|", '格式输入不正确'],
         'alpha'         =>  ["|^[a-zA-Z]+$|", '必须为英文字母格式'],
         'zh'            =>  ['/^[\x{4e00}-\x{9fa5}]+$/u', '必须为中文'],
         'price'         =>  ["/^[0-9]+([.]{1}[0-9]{1,2})?$/", '必须为金额格式'],

+ 8 - 2
common/models/ReceiveAddress.php

@@ -15,6 +15,8 @@ use Yii;
  * @property int $PROVINCE 省份名称
  * @property int $CITY 城市名称
  * @property int $COUNTY 县区名称
+ * @property string $LGA_NAME Lga
+ * @property string $CITY_NAME City
  * @property string $ADDRESS 详细地址
  * @property int $IS_DEFAULT 是否默认
  * @property int $CREATED_AT 创建时间
@@ -37,13 +39,15 @@ class ReceiveAddress extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'USER_NAME', 'CONSIGNEE', 'MOBILE', 'PROVINCE', 'CITY', 'COUNTY', 'ADDRESS'], 'required'],
-            [['PROVINCE', 'CITY', 'COUNTY', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
+            [['USER_ID', 'USER_NAME', 'CONSIGNEE', 'MOBILE', 'PROVINCE', 'LGA_NAME', 'CITY_NAME', 'ADDRESS'], 'required'],
+            [['PROVINCE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
             [['ID', 'USER_ID'], 'string', 'max' => 32],
             [['USER_NAME'], 'string', 'max' => 16],
             [['CONSIGNEE'], 'string', 'max' => 120],
             [['MOBILE'], 'string', 'max' => 11],
             [['ADDRESS'], 'string', 'max' => 255],
+            [['LGA_NAME'], 'string', 'max' => 50],
+            [['CITY_NAME'], 'string', 'max' => 50],
             [['UPDATER'], 'string', 'max' => 10],
             [['ID'], 'unique'],
         ];
@@ -63,6 +67,8 @@ class ReceiveAddress extends \common\components\ActiveRecord
             'PROVINCE' => '省份名称',
             'CITY' => '城市名称',
             'COUNTY' => '县区名称',
+            'LGA_NAME' => 'Lga Name',
+            'CITY_NAME' => 'City Name',
             'ADDRESS' => '详细地址',
             'IS_DEFAULT' => '是否默认',
             'CREATED_AT' => '创建时间',

+ 5 - 2
common/models/Region.php

@@ -70,6 +70,7 @@ class Region extends \common\components\ActiveRecord
      * @return string
      */
     public static function getCnName($regionCode){
+//        self::updateToCache();
         $allData = self::getFromCache();
         return $allData[$regionCode]['REGION_NAME'] ?? '';
     }
@@ -115,8 +116,10 @@ class Region extends \common\components\ActiveRecord
     public static function getWarehouseByCode($regionCode){
         //'540000','710000','810000','820000'
         $ZoningArr = [
-            '01'=>['110000','120000','130000','370000','140000','210000','310000','320000','330000','340000','410000','150000','220000','230000','500000','510000','610000','620000','640000','630000','650000'],
-            '02'=>['440000','350000','360000','420000','430000','450000','460000','520000','530000']
+            '01'=>['10100','10200','10300','10400','10500','10600','10700','10800','10900',
+                '11000','11100','11200','11300','11400','11500','11600','11700','11800',
+                '11900','12000','12100','12200','12300','12400','12500','12600','12700',
+                '12800','12900','13000','13100','13200','13300','13400','13500','13600','19900']
         ];
         $zoning = '';
         foreach ($ZoningArr as $key=>$val){

+ 16 - 11
common/models/forms/ReceiveAddressForm.php

@@ -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();

+ 5 - 3
frontendApi/modules/v1/controllers/ConfigController.php

@@ -9,6 +9,7 @@ namespace frontendApi\modules\v1\controllers;
 
 use common\helpers\Cache;
 use common\helpers\Form;
+use common\helpers\snowflake\SnowFake;
 use common\models\forms\ReceiveAddressForm;
 use common\models\forms\UserConfigForm;
 use common\models\ReceiveAddress;
@@ -86,17 +87,18 @@ class ConfigController extends BaseController
         $condition = ' AND USER_ID=:USER_ID';
         $params[':USER_ID'] = \Yii::$app->user->id;
         $data = ReceiveAddress::lists($condition, $params, [
-            'SELECT' => 'ID,CONSIGNEE,MOBILE,PROVINCE,CITY,COUNTY,ADDRESS,IS_DEFAULT',
+            'SELECT' => 'ID,CONSIGNEE,MOBILE,PROVINCE,LGA_NAME,CITY_NAME,ADDRESS,IS_DEFAULT',
             'orderBy' => 'IS_DEFAULT DESC,CREATED_AT DESC',
             'useSlaves' => true,
         ]);
         if($data['list']){
             foreach($data['list'] as $key=>$row){
                 $data['list'][$key]['PROVINCE_NAME'] = Region::getCnName($row['PROVINCE']);
-                $data['list'][$key]['CITY_NAME'] = Region::getCnName($row['CITY']);
-                $data['list'][$key]['COUNTY_NAME'] = Region::getCnName($row['COUNTY']);
+//                $data['list'][$key]['CITY_NAME'] = Region::getCnName($row['CITY']);
+//                $data['list'][$key]['COUNTY_NAME'] = Region::getCnName($row['COUNTY']);
             }
         }
+//        print_r($data);exit;
         return static::notice($data);
     }
 

+ 34 - 13
frontendEle/src/views/config/receive-address-edit.vue

@@ -16,6 +16,27 @@
           </template>
           <el-input v-model="form.mobile"></el-input>
         </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            House Number & Street Name
+          </template>
+          <el-input v-model="form.address"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            City
+          </template>
+          <el-input v-model="form.cityName"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            Local Government Area
+          </template>
+          <el-input v-model="form.lgaName"></el-input>
+        </el-form-item>
         <el-form-item prop="areaSelected">
           <template slot="label">
             <span class="text-danger">*</span>
@@ -27,13 +48,7 @@
             v-model="form.areaSelected">
           </el-cascader>
         </el-form-item>
-        <el-form-item>
-          <template slot="label">
-            <span class="text-danger">*</span>
-            详细地址
-          </template>
-          <el-input v-model="form.address"></el-input>
-        </el-form-item>
+
         <el-form-item>
           <template slot="label">
             是否默认
@@ -87,8 +102,10 @@
           consignee: this.form.consignee,
           mobile: this.form.mobile,
           province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
-          city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
-          county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
+          // city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
+          // county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
+          lgaName: this.form.lgaName,
+          cityName: this.form.cityName,
           address: this.form.address,
           isDefault: this.form.isDefault,
         }
@@ -99,8 +116,10 @@
             consignee: this.form.consignee,
             mobile: this.form.mobile,
             province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
-            city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
-            county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
+            // city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
+            // county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
+            lgaName: this.form.lgaName,
+            cityName: this.form.cityName,
             address: this.form.address,
             isDefault: this.form.isDefault,
           }
@@ -122,8 +141,10 @@
           this.form.consignee = response.CONSIGNEE
           this.form.mobile = response.MOBILE
           this.form.areaSelected[0] = response.PROVINCE
-          this.form.areaSelected[1] = response.CITY
-          this.form.areaSelected[2] = response.COUNTY
+          // this.form.areaSelected[1] = response.CITY
+          // this.form.areaSelected[2] = response.COUNTY
+          this.form.lgaName = response.LGA_NAME
+          this.form.cityName = response.CITY_NAME
           this.form.address = response.ADDRESS
           this.form.isDefault = response.IS_DEFAULT === '1' ? true : false
           this.loading = false

+ 4 - 4
frontendEle/src/views/config/receive-address-list.vue

@@ -4,10 +4,10 @@
       <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;">
         <el-table-column label="收货人" prop="CONSIGNEE" width="150"></el-table-column>
         <el-table-column label="手机号码" prop="MOBILE" width="150"></el-table-column>
-        <el-table-column label="省/市" prop="PROVINCE_NAME" width="150"></el-table-column>
-        <el-table-column label="市/区" prop="CITY_NAME" width="150"></el-table-column>
-        <el-table-column label="区/县" prop="COUNTY_NAME" width="150"></el-table-column>
-        <el-table-column label="详细地址" prop="ADDRESS" ></el-table-column>
+        <el-table-column label="House" prop="ADDRESS" width="350"></el-table-column>
+        <el-table-column label="City" prop="CITY_NAME" width="150"></el-table-column>
+        <el-table-column label="Local Government Area" prop="LGA_NAME" width="150"></el-table-column>
+        <el-table-column label="State" prop="PROVINCE_NAME" width="150"></el-table-column>
         <el-table-column label="是否默认" width="100">
           <template slot-scope="scope">
             {{scope.row.IS_DEFAULT === '1' ? '是' : '否'}}