Ver código fonte

Merge branch 'master' of http://git.dever.cc:3000/dever-package/passport

dever 3 anos atrás
pai
commit
9205e05f6c
4 arquivos alterados com 103 adições e 14 exclusões
  1. 13 0
      database/address.php
  2. 13 0
      database/invoice.php
  3. 58 14
      src/Address.php
  4. 19 0
      src/Invoice.php

+ 13 - 0
database/address.php

@@ -234,5 +234,18 @@ return array
 			'page' => array(10, 'list'),
 			'col' => '*',
 		),
+
+        'updateType' => array
+        (
+            'set' => array
+            (
+                'type' => 'yes',
+            ),
+            'where' => array
+            (
+                'type' => 'yes',
+            ),
+            'type' => 'update',
+        ),
     ),
 );

+ 13 - 0
database/invoice.php

@@ -208,5 +208,18 @@ return array
             'page' => array(10, 'list'),
             'col' => '*',
         ),
+
+        'updateType' => array
+        (
+            'set' => array
+            (
+                'type' => 'yes',
+            ),
+            'where' => array
+            (
+                'type' => 'yes',
+            ),
+            'type' => 'update',
+        ),
     ),
 );

+ 58 - 14
src/Address.php

@@ -47,20 +47,37 @@ class Address  extends Base
 
     private function getInfo($data)
     {
-        $info = Dever::db('area/province')->find($data['province']);
-        $data['province_name'] = $info['name'];
+        if ($data['province'] && $data['city'] && $data['county']) {
+            $info = Dever::db('area/province')->find($data['province']);
+            $data['province_name'] = $info['name'];
 
-        $info = Dever::db('area/city')->find($data['city']);
-        $data['city_name'] = $info['name'];
+            $info = Dever::db('area/city')->find($data['city']);
+            $data['city_name'] = $info['name'];
 
-        $info = Dever::db('area/county')->find($data['county']);
-        $data['county_name'] = $info['name'];
+            $info = Dever::db('area/county')->find($data['county']);
+            $data['county_name'] = $info['name'];
 
-        $data['add_string'] = $data['province_name'] . $data['city_name'] . $data['county_name'] .','. $data['address'] .','. $data['house_number'] .','. $data['contact'] .','. $data['mobile'];
+            $data['add_string'] = $data['province_name'] . $data['city_name'] . $data['county_name'] .','. $data['address'] .','. $data['house_number'] .','. $data['contact'] .','. $data['mobile'];
+        }
 
         return $data;
     }
 
+    # 删除和恢复
+    public function del($uid, $id, $state = 2)
+    {
+        $info = $this->getOne($uid, $id);
+        if ($info) {
+            $update['where_id'] = $info['id'];
+            $update['state'] = $state;
+            Dever::db('passport/address')->update($update);
+        } else {
+            Dever::alert('更新失败');
+        }
+
+        return 'ok';
+    }
+
     # 添加或者更新地址接口
     public function up()
     {
@@ -70,32 +87,53 @@ class Address  extends Base
         $province = Dever::input('province');
         $city = Dever::input('city');
         $county = Dever::input('county');
+        $contact = Dever::input('contact');
         $address = Dever::input('address');
         $country = Dever::input('country');
+        $mobile = Dever::input('mobile');
         $sex = Dever::input('sex');
         $house_number = Dever::input('house_number');
         $tag = Dever::input('tag');
 
-        return $this->upAddress($id, $uid, $type, $province, $city, $county, $address, $country, $sex, $house_number, $tag);
+        return $this->upAddress($id, $uid, $type, $mobile, $contact, $province, $city, $county, $address, $country, $sex, $house_number, $tag);
     }
 
     # 添加或者更新地址
-    public function upAddress($id, $uid, $type = 2, $province = '', $city = '', $county = '', $address = '', $country = '', $sex = '', $house_number = '', $tag = '')
+    public function upAddress($id, $uid, $type = 2, $mobile, $contact, $province = '', $city = '', $county = '', $address = '', $country = '', $sex = '', $house_number = '', $tag = '')
     {
+        if ($contact) {
+            $update['contact'] = $contact;
+        }
+        
     	if ($country) {
     		$update['country'] = $country;
     	}
+
+        if ($mobile) {
+            $update['mobile'] = $mobile;
+        }
+
+        if ($province) {
+            $update['province'] = $province;
+        }
+
+        if ($city) {
+            $update['city'] = $city;
+        }
+
+        if ($county) {
+            $update['county'] = $county;
+        }
         
-        if ($province && $city && $county && $address) {
-        	$update['province'] = $province;
-	        $update['city'] = $city;
-	        $update['county'] = $county;
+        if ($province && $city && $county) {
 	        $update['area'] = $province . ',' . $city . ',' . $county;
-	        $update['address'] = $address;
         }
 
         $update['type'] = $type;
 
+        if ($address) {
+            $update['address'] = $address;
+        }
         if ($sex) {
             $update['sex'] = $sex;
         }
@@ -105,6 +143,10 @@ class Address  extends Base
         if ($tag) {
             $update['tag'] = $tag;
         }
+
+        if ($type == 2) {
+            Dever::db('passport/address')->updateType(array('where_type' => 2, 'set_type' => 1));
+        }
         
         if ($id) {
             $update['where_id'] = $id;
@@ -114,6 +156,8 @@ class Address  extends Base
             $id = Dever::db('passport/address')->insert($update);
         }
 
+
+
         return $id;
     }
 }

+ 19 - 0
src/Invoice.php

@@ -43,6 +43,21 @@ class Invoice  extends Base
         return $data;
     }
 
+    # 删除和恢复
+    public function del($uid, $id, $state = 2)
+    {
+        $info = $this->getOne($uid, $id);
+        if ($info) {
+            $update['where_id'] = $info['id'];
+            $update['state'] = $state;
+            Dever::db('passport/invoice')->update($update);
+        } else {
+            Dever::alert('更新失败');
+        }
+
+        return 'ok';
+    }
+
     # 添加或者更新地址接口
     public function up()
     {
@@ -98,6 +113,10 @@ class Invoice  extends Base
         if ($bank_number) {
             $update['bank_number'] = $bank_number;
         }
+
+        if ($type == 2) {
+            Dever::db('passport/invoice')->updateType(array('where_type' => 2, 'set_type' => 1));
+        }
         
         if ($id) {
             $update['where_id'] = $id;