dever vor 6 Jahren
Ursprung
Commit
fdbade364b
7 geänderte Dateien mit 287 neuen und 61 gelöschten Zeilen
  1. 114 28
      doc/api_data.js
  2. 114 28
      doc/api_data.json
  3. 1 1
      doc/api_project.js
  4. 1 1
      doc/api_project.json
  5. 22 0
      doc/apidoc.php
  6. 3 3
      product/database/address.php
  7. 32 0
      product/src/Api.php

+ 114 - 28
doc/api_data.js

@@ -447,12 +447,12 @@ define({ "api": [
   },
   {
     "type": "get",
-    "url": "product/?l=api.addCarts",
-    "title": "添加产品到购物车",
+    "url": "product/?l=api.addAddress",
+    "title": "添加收货地址",
     "version": "1.0.0",
-    "name": "api_addCarts",
+    "name": "api_addAddress",
     "group": "Product",
-    "description": "<p>添加产品到购物车</p>",
+    "description": "<p>添加收货地址</p>",
     "parameter": {
       "fields": {
         "Parameter": [
@@ -467,15 +467,22 @@ define({ "api": [
             "group": "Parameter",
             "type": "String",
             "optional": false,
-            "field": "product_id",
-            "description": "<p>产品id</p>"
+            "field": "name",
+            "description": "<p>收货人姓名</p>"
           },
           {
             "group": "Parameter",
             "type": "String",
             "optional": false,
-            "field": "num",
-            "description": "<p>数量</p>"
+            "field": "address",
+            "description": "<p>收货人地址</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "mobile",
+            "description": "<p>收货人联系电话</p>"
           }
         ]
       }
@@ -498,12 +505,12 @@ define({ "api": [
   },
   {
     "type": "get",
-    "url": "product/?l=api.carts",
-    "title": "获取购物车列表",
+    "url": "product/?l=api.addCarts",
+    "title": "添加产品到购物车",
     "version": "1.0.0",
-    "name": "api_buy",
+    "name": "api_addCarts",
     "group": "Product",
-    "description": "<p>获取购物车列表</p>",
+    "description": "<p>添加产品到购物车</p>",
     "parameter": {
       "fields": {
         "Parameter": [
@@ -513,6 +520,20 @@ define({ "api": [
             "optional": false,
             "field": "signature",
             "description": "<p>signature</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "product_id",
+            "description": "<p>产品id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "num",
+            "description": "<p>数量</p>"
           }
         ]
       }
@@ -520,26 +541,12 @@ define({ "api": [
     "success": {
       "fields": {
         "Success 200": [
-          {
-            "group": "Success 200",
-            "type": "Object[]",
-            "optional": false,
-            "field": "carts",
-            "description": "<p>购物车信息</p>"
-          },
           {
             "group": "Success 200",
             "type": "String",
             "optional": false,
-            "field": "carts.product",
-            "description": "<p>产品信息</p>"
-          },
-          {
-            "group": "Success 200",
-            "type": "String",
-            "optional": false,
-            "field": "carts.num",
-            "description": "<p>数量</p>"
+            "field": "data",
+            "description": "<p>返回ok</p>"
           }
         ]
       }
@@ -626,6 +633,85 @@ define({ "api": [
     "filename": "/root/input/doc/apidoc.php",
     "groupTitle": "Product"
   },
+  {
+    "type": "get",
+    "url": "product/?l=api.carts",
+    "title": "获取购物车列表",
+    "version": "1.0.0",
+    "name": "api_buy",
+    "group": "Product",
+    "description": "<p>获取购物车列表</p>",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "signature",
+            "description": "<p>signature</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "fields": {
+        "Success 200": [
+          {
+            "group": "Success 200",
+            "type": "Object[]",
+            "optional": false,
+            "field": "carts",
+            "description": "<p>购物车信息</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "carts.product",
+            "description": "<p>产品信息</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "carts.num",
+            "description": "<p>数量</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "Object[]",
+            "optional": false,
+            "field": "address",
+            "description": "<p>收货地址</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "address.name",
+            "description": "<p>收货人姓名</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "address.address",
+            "description": "<p>收货人地址</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "address.mobile",
+            "description": "<p>收货人联系电话</p>"
+          }
+        ]
+      }
+    },
+    "filename": "/root/input/doc/apidoc.php",
+    "groupTitle": "Product"
+  },
   {
     "type": "get",
     "url": "product/?l=api.code",

+ 114 - 28
doc/api_data.json

@@ -447,12 +447,12 @@
   },
   {
     "type": "get",
-    "url": "product/?l=api.addCarts",
-    "title": "添加产品到购物车",
+    "url": "product/?l=api.addAddress",
+    "title": "添加收货地址",
     "version": "1.0.0",
-    "name": "api_addCarts",
+    "name": "api_addAddress",
     "group": "Product",
-    "description": "<p>添加产品到购物车</p>",
+    "description": "<p>添加收货地址</p>",
     "parameter": {
       "fields": {
         "Parameter": [
@@ -467,15 +467,22 @@
             "group": "Parameter",
             "type": "String",
             "optional": false,
-            "field": "product_id",
-            "description": "<p>产品id</p>"
+            "field": "name",
+            "description": "<p>收货人姓名</p>"
           },
           {
             "group": "Parameter",
             "type": "String",
             "optional": false,
-            "field": "num",
-            "description": "<p>数量</p>"
+            "field": "address",
+            "description": "<p>收货人地址</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "mobile",
+            "description": "<p>收货人联系电话</p>"
           }
         ]
       }
@@ -498,12 +505,12 @@
   },
   {
     "type": "get",
-    "url": "product/?l=api.carts",
-    "title": "获取购物车列表",
+    "url": "product/?l=api.addCarts",
+    "title": "添加产品到购物车",
     "version": "1.0.0",
-    "name": "api_buy",
+    "name": "api_addCarts",
     "group": "Product",
-    "description": "<p>获取购物车列表</p>",
+    "description": "<p>添加产品到购物车</p>",
     "parameter": {
       "fields": {
         "Parameter": [
@@ -513,6 +520,20 @@
             "optional": false,
             "field": "signature",
             "description": "<p>signature</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "product_id",
+            "description": "<p>产品id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "num",
+            "description": "<p>数量</p>"
           }
         ]
       }
@@ -520,26 +541,12 @@
     "success": {
       "fields": {
         "Success 200": [
-          {
-            "group": "Success 200",
-            "type": "Object[]",
-            "optional": false,
-            "field": "carts",
-            "description": "<p>购物车信息</p>"
-          },
           {
             "group": "Success 200",
             "type": "String",
             "optional": false,
-            "field": "carts.product",
-            "description": "<p>产品信息</p>"
-          },
-          {
-            "group": "Success 200",
-            "type": "String",
-            "optional": false,
-            "field": "carts.num",
-            "description": "<p>数量</p>"
+            "field": "data",
+            "description": "<p>返回ok</p>"
           }
         ]
       }
@@ -626,6 +633,85 @@
     "filename": "/root/input/doc/apidoc.php",
     "groupTitle": "Product"
   },
+  {
+    "type": "get",
+    "url": "product/?l=api.carts",
+    "title": "获取购物车列表",
+    "version": "1.0.0",
+    "name": "api_buy",
+    "group": "Product",
+    "description": "<p>获取购物车列表</p>",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "String",
+            "optional": false,
+            "field": "signature",
+            "description": "<p>signature</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "fields": {
+        "Success 200": [
+          {
+            "group": "Success 200",
+            "type": "Object[]",
+            "optional": false,
+            "field": "carts",
+            "description": "<p>购物车信息</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "carts.product",
+            "description": "<p>产品信息</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "carts.num",
+            "description": "<p>数量</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "Object[]",
+            "optional": false,
+            "field": "address",
+            "description": "<p>收货地址</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "address.name",
+            "description": "<p>收货人姓名</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "address.address",
+            "description": "<p>收货人地址</p>"
+          },
+          {
+            "group": "Success 200",
+            "type": "String",
+            "optional": false,
+            "field": "address.mobile",
+            "description": "<p>收货人联系电话</p>"
+          }
+        ]
+      }
+    },
+    "filename": "/root/input/doc/apidoc.php",
+    "groupTitle": "Product"
+  },
   {
     "type": "get",
     "url": "product/?l=api.code",

+ 1 - 1
doc/api_project.js

@@ -13,7 +13,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-09-20T04:12:50.875Z",
+    "time": "2018-09-20T07:58:21.208Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 1 - 1
doc/api_project.json

@@ -13,7 +13,7 @@
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-09-20T04:12:50.875Z",
+    "time": "2018-09-20T07:58:21.208Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 22 - 0
doc/apidoc.php

@@ -281,4 +281,26 @@
  * @apiSuccess {Object[]} carts 购物车信息
  * @apiSuccess {String}   carts.product 产品信息
  * @apiSuccess {String}   carts.num 数量
+
+ * @apiSuccess {Object[]} address 收货地址
+ * @apiSuccess {String}   address.name 收货人姓名
+ * @apiSuccess {String}   address.address 收货人地址
+ * @apiSuccess {String}   address.mobile 收货人联系电话
+ */
+
+
+/**
+ * @api {get} product/?l=api.addAddress 添加收货地址
+ * @apiVersion 1.0.0
+ * @apiName api.addAddress
+ * @apiGroup Product
+ *
+ * @apiDescription 添加收货地址
+ *
+ * @apiParam {String} signature signature
+ * @apiParam {String} name 收货人姓名
+ * @apiParam {String} address 收货人地址
+ * @apiParam {String} mobile 收货人联系电话
+ *
+ * @apiSuccess {String}   data 返回ok
  */

+ 3 - 3
product/database/address.php

@@ -82,9 +82,9 @@ return array
 			'default' 	=> '1',
 			'desc' 		=> '是否默认地址',
 			'match' 	=> 'is_numeric',
-			'update'	=> 'radio',
-			'option'	=> $status,
-			'list'		=> true,
+			//'update'	=> 'radio',
+			//'option'	=> $status,
+			//'list'		=> true,
 		),
 
 		'state'		=> array

+ 32 - 0
product/src/Api.php

@@ -220,6 +220,38 @@ class Api extends Base
             }
         }
 
+        $this->data['address'] = Dever::db('product/address')->one($where);
+
         return $this->data;
     }
+
+    # 添加收货地址
+    public function addAddress()
+    {
+        $name = Dever::input('name');
+        $mobile = Dever::input('mobile');
+        $address = Dever::input('address');
+        $uid = $this->data['uid'];
+        if ($name && $mobile && $address) {
+            $update = array();
+            $update['product_id'] = $product_id;
+            $update['uid'] = $this->data['uid'];
+            
+            $info = Dever::db('product/address')->one($update);
+            if ($info) {
+                $update['where_id'] = $info['id'];
+                $update['name'] = $name;
+                $update['mobile'] = $mobile;
+                $update['address'] = $address;
+                Dever::db('product/address')->update($update);
+            } else {
+                $update['name'] = $name;
+                $update['mobile'] = $mobile;
+                $update['address'] = $address;
+                Dever::db('product/address')->insert($update);
+            }
+        }
+
+        return 'ok';
+    }
 }