瀏覽代碼

修改接口文档

chenxiqiang 6 年之前
父節點
當前提交
6596ea8ab5

+ 88
- 1
manage-server/app/Http/Controllers/CommonController.php 查看文件

@@ -2,6 +2,11 @@
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
+use App\Models\HouseApplianceCleanOrder;
6
+use App\Models\HouseCleanOrder;
7
+use App\Models\HousekeeperOrder;
8
+use App\Models\MaternityMatronOrder;
9
+use App\Models\ProductOrder;
5 10
 use Illuminate\Http\Request;
6 11
 
7 12
 class CommonController extends Controller
@@ -31,9 +36,91 @@ class CommonController extends Controller
31 36
         } catch (Exception $e) {
32 37
             return response()->json([
33 38
                 'status' => -2,
34
-                'message' => "error,".$e->getCode().": ".$e->getMessage()
39
+                'message' => "error," . $e->getCode() . ": " . $e->getMessage()
35 40
             ]);
36 41
         }
37 42
 
38 43
     }
44
+
45
+
46
+    /**
47
+     * 添加评论, 一个订单只能评价一次
48
+     * @param Request $request
49
+     * @return \Illuminate\Http\JsonResponse
50
+     */
51
+    public function addComment(Request $request,$order_id, $order_type)
52
+    {
53
+        $order_id = $request->route("order_id");
54
+        $order_type = $request->route("order_type");
55
+        $title = $request->input("title");
56
+        $content = $request->input("content");
57
+        $code = $request->input('code');
58
+        $miniProgram = EasyWeChat::miniProgram();
59
+        $auth = $miniProgram->auth->session($code);
60
+        $wechat_id = "";
61
+        if ($order_id && $title && $content) {
62
+            $comment = new Comment;
63
+            $comment->order_id = $order_id;
64
+            $comment->order_type = $order_type;
65
+            $comment->title = $title;
66
+            $comment->content = $content;
67
+            $comment->show = 0;
68
+            $comment->wechat_id = $wechat_id;
69
+            $comment->save();
70
+            return Response()->json([
71
+                "status" => 0,
72
+                "message" => "保存成功!"
73
+            ]);
74
+        } else {
75
+            return Response()->json([
76
+                "status" => -1,
77
+                "message" => "信息不能为空!"
78
+            ]);
79
+        }
80
+    }
81
+
82
+    /**
83
+     * 分页获取订单评论
84
+     * @param Request $request
85
+     * @return mixed
86
+     */
87
+    public function comments(Request $request, $order_type, $order_id)
88
+    {
89
+        $order_id = $request->input("order_id");
90
+        $order_type = $request->route("order_type");
91
+        if ($order_id) {
92
+            return Comment::where("order_id", $order_id)->where("type", $order_type)->paginate(20);
93
+        }
94
+    }
95
+
96
+    /**
97
+     * 获取我的订单
98
+     * @param Request $request
99
+     * @return \Illuminate\Http\JsonResponse
100
+     */
101
+    public function orders(Request $request)
102
+    {
103
+
104
+        $code = $request->input('code');
105
+        $miniProgram = EasyWeChat::miniProgram();
106
+        $auth = $miniProgram->auth->session($code);
107
+        $wechat_id = "";
108
+        $houseApplianceCleanOrder = HouseApplianceCleanOrder::where("wechat_id", $wechat_id)->get();
109
+        $houseCleanOrder = HouseCleanOrder::where("wechat_id", $wechat_id)->get();
110
+        $housekeeperOrder = HousekeeperOrder::where("wechat_id", $wechat_id)->get();
111
+        $maternityMatronOrder = MaternityMatronOrder::where("wechat_id", $wechat_id)->get();
112
+        $productOrder = ProductOrder::where("wechat_id", $wechat_id)->get();
113
+
114
+        return Response()->json([
115
+            "status" => 0,
116
+            "data" => [
117
+                "houseApplianceCleanOrder" => $houseApplianceCleanOrder,
118
+                "houseCleanOrder" => $houseCleanOrder,
119
+                "housekeeperOrder" => $housekeeperOrder,
120
+                "maternityMatronOrder" => $maternityMatronOrder,
121
+                "productOrder" => $productOrder
122
+            ]
123
+        ]);
124
+
125
+    }
39 126
 }

+ 1
- 1
manage-server/app/Http/Controllers/ProductOrderController.php 查看文件

@@ -101,7 +101,7 @@ class ProductOrderController extends Controller
101 101
     public function get(Request $request)
102 102
     {
103 103
         $id = $request->input("id");
104
-        if($id) {
104
+        if ($id) {
105 105
             $data = ProductOrder::find($id);
106 106
             return Response()->json([
107 107
                 "status" => 0,

+ 18
- 0
manage-server/app/Models/Comment.php 查看文件

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+namespace App\Models;
4
+
5
+use Illuminate\Database\Eloquent\Model;
6
+
7
+class Comment extends Model
8
+{
9
+
10
+    protected $fillable = [
11
+        'wechat_id', // wechat
12
+        'order_type', // 订单类型
13
+        'order_id', // 订单id
14
+        'title', // 评论标题
15
+        'content', // 评论内容
16
+        'show' // 是否可视0, 1
17
+    ];
18
+}

+ 1
- 0
manage-server/app/Models/ProductOrder.php 查看文件

@@ -15,6 +15,7 @@ class ProductOrder extends Model
15 15
         'wechat_id', // 微信号id(open_id)
16 16
     	'product_id', // 产品名称
17 17
 		'product_name', // 产品信息
18
+        'color', // 产品颜色款色
18 19
 		'unit', // 产品单格
19 20
 		'amount', // 产品数量
20 21
 		'price', // 订单总价

+ 34
- 0
manage-server/database/migrations/2018_08_14_080203_create_comments_table.php 查看文件

@@ -0,0 +1,34 @@
1
+<?php
2
+
3
+use Illuminate\Support\Facades\Schema;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Database\Migrations\Migration;
6
+
7
+class CreateCommentsTable extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     *
12
+     * @return void
13
+     */
14
+    public function up()
15
+    {
16
+        Schema::create('comments', function (Blueprint $table) {
17
+            $table->increments('id');
18
+            $table->string('title');
19
+            $table->string('content');
20
+            $table->integer('show');
21
+            $table->timestamps();
22
+        });
23
+    }
24
+
25
+    /**
26
+     * Reverse the migrations.
27
+     *
28
+     * @return void
29
+     */
30
+    public function down()
31
+    {
32
+        Schema::dropIfExists('comments');
33
+    }
34
+}

+ 342
- 23
manage-server/readme.md 查看文件

@@ -27,6 +27,125 @@ photo       |   png/jpeg  | 	必须  |  图片
27 27
 }
28 28
 ```
29 29
 
30
+### 添加订单评论
31
+- `POST /{order_type}/{order_id}/comment`
32
+- 参数:
33
+参数         |  类型    |   可选  |    备注
34
+----------- |  ------  |  ------   |  --------
35
+title       |  string  |  必须      |   订单评论标题
36
+content     |  string  | 必须       |   评论内容
37
+code        |  string  | 	必须     |  小程序code
38
+
39
+- 响应:
40
+
41
+```
42
+{
43
+	"status": 0,
44
+	"message": "保存成功"
45
+}
46
+
47
+{
48
+	"status": -1,
49
+	"message": "信息不能为空!"
50
+}
51
+```
52
+
53
+### 分页获取订单评论
54
+- `GET /{order_type}/{order_id}/comments`
55
+- 参数: 无
56
+- 响应:
57
+
58
+```
59
+{
60
+   "total": 50,
61
+   "per_page": 15,
62
+   "current_page": 1,
63
+   "last_page": 4,
64
+   "first_page_url": "http://laravel.app?page=1",
65
+   "last_page_url": "http://laravel.app?page=4",
66
+   "next_page_url": "http://laravel.app?page=2",
67
+   "prev_page_url": null,
68
+   "path": "http://laravel.app",
69
+   "from": 1,
70
+   "to": 15,
71
+   "data":[{
72
+			"id": 123456,
73
+			"wechat_id": "wechat_id",
74
+			"title": "测试标题",
75
+			"content": "测试内容",
76
+			"show": 0, // 预留字段, 0可视, 1隐藏
77
+			"created_at": "2018-02-16 11:10:56",
78
+			"updated_at": "2018-02-16 12:00:51"
79
+		},
80
+		...
81
+   ]
82
+}
83
+```
84
+
85
+### 我的订单
86
+- `GET /my/orders`
87
+- 参数:
88
+
89
+参数         |  类型    |   可选               |    备注
90
+----------- |  ------  |  ------------------ |  --------
91
+code        |  string  | 	必须               |  小程序code
92
+
93
+- 响应:
94
+
95
+```
96
+{
97
+	"status": 0,
98
+	"data": {
99
+		"houseApplianceCleanOrder": [
100
+			{
101
+				"id": 123456,
102
+				"wechat_id": "wechat_id",
103
+				"appliances": "清洁项目1, 清洁项目1, 清洁项目2, 清洁项目3",
104
+				"adress": "地址",
105
+				"contact": "联系人",
106
+				"phone": "13800138000",
107
+				"price": 12.3,
108
+				"status": 0, // 0.待处理 1.商家受理 2.待支付 3.已支付
109
+				"created_at": "2018-02-16 11:10:56",
110
+				"updated_at": "2018-02-16 12:00:51"
111
+			},
112
+			...
113
+		],
114
+		"houseCleanOrder": [
115
+			{
116
+				"id": 123456,
117
+				"wechat_id": "微信id",
118
+				"type": "清洁类型",
119
+				"area": "清洁面积",
120
+				"adress": "地址",
121
+				"contact": "联系人",
122
+				"phone": "13800138000",
123
+				"price": 12.3,
124
+				"status": 0, // 0.待处理 1.商家受理 2.待支付 3.已支付
125
+				"picture1": "/commom/picture1.jepg",
126
+				"picture2": "/commom/picture2.jepg",
127
+				"picture3": "/commom/picture3.jepg",
128
+				"picture4": "/commom/picture4.jepg",
129
+				"picture5": "/commom/picture5.jepg",
130
+				"created_at": "2018-02-16 11:10:56",
131
+				"updated_at": "2018-02-16 12:00:51"
132
+			},
133
+			...
134
+		],
135
+		"housekeeperOrder": [
136
+		
137
+		],
138
+		"maternityMatronOrder": [
139
+		
140
+		],
141
+		"productOrder": [
142
+		
143
+		]
144
+	}
145
+}
146
+```
147
+
148
+
30 149
 ## 活动接口
31 150
 ### 创建/修改活动
32 151
 - `POST /campaign/store`
@@ -117,13 +236,6 @@ status      |  integer | 	可选,默认0          |  活动状态:0.进行中,
117 236
 			"status": 0,
118 237
 			"created_at": "2018-02-16 11:10:56",
119 238
 			"updated_at": "2018-02-16 12:00:51"
120
-		},{
121
-			"id": 34578,
122
-			"title": "测试标题2",
123
-			"content": "测试内容2",
124
-			"status": 1,
125
-			"created_at": "2018-02-16 11:10:56",
126
-			"updated_at": "2018-02-16 12:00:51"
127 239
 		},
128 240
 		...
129 241
    ]
@@ -204,8 +316,8 @@ status      |  integer | 	可选,默认0          |  产品状态:0.上架, 1.
204 316
 ```
205 317
 
206 318
 
207
-### 分页查询活动
208
-- `GET /campaigns`
319
+### 分页查询产品
320
+- `GET /products`
209 321
 - 参数: 无
210 322
 - 响应:
211 323
 
@@ -228,23 +340,13 @@ status      |  integer | 	可选,默认0          |  产品状态:0.上架, 1.
228 340
 			"info": "测试信息",
229 341
 			"price": 1234.31,
230 342
 			"classify": "分类1",
343
+			"color": "款色",
231 344
 			"collect_num": 765,  //收藏数
232 345
 			"sell_num": 5,       //销量
233 346
 			"status": 0,         //0上架, 1下架
234 347
 			"created_at": "2018-02-16 11:10:56",
235 348
 			"updated_at": "2018-02-16 12:00:51"
236
-		}, {
237
-			"id": 123456,
238
-			"name": "测试名称",
239
-			"info": "测试信息",
240
-			"price": 1234.31,
241
-			"classify": "分类1",
242
-			"collect_num": 765,  //收藏数
243
-			"sell_num": 5,       //销量
244
-			"status": 0,         //0上架, 1下架
245
-			"created_at": "2018-02-16 11:10:56",
246
-			"updated_at": "2018-02-16 12:00:51"
247
-		}
349
+		}, 
248 350
 		...
249 351
    ]
250 352
 }
@@ -252,7 +354,7 @@ status      |  integer | 	可选,默认0          |  产品状态:0.上架, 1.
252 354
 
253 355
 ## 家居清洁订单接口
254 356
 ### 创建/修改家居清洁订单
255
-- `POST /house_clean/store`
357
+- `POST /house_clean_order/store`
256 358
 - 参数:
257 359
 
258 360
 参数         |  类型    |   可选               |    备注
@@ -273,4 +375,221 @@ picture4    | string   |  可选                | 图片链接
273 375
 picture5    | string   |  可选                | 图片链接
274 376
 
275 377
 - 响应:
276
-- 
378
+
379
+```
380
+{
381
+	"status": 0,
382
+	"message": "保存成功"
383
+}
384
+
385
+{
386
+	"status": -1,
387
+	"message": "信息不能为空!"
388
+}
389
+```
390
+
391
+### 删除订单
392
+- `DELETE /house_clean_order/delete/${id}`
393
+- 参数:无
394
+
395
+- 响应:
396
+
397
+ ```
398
+{
399
+	"status": 0,
400
+	"message": "删除成功"
401
+}
402
+
403
+{
404
+	"status": -1,
405
+	"message": "id不能为空!"
406
+}
407
+```
408
+
409
+### 获得某订单
410
+
411
+- `GET /house_clean_order/${id}`
412
+- 参数:无
413
+
414
+- 响应:
415
+
416
+ ```
417
+{
418
+	"status": 0,
419
+	"data": {
420
+		"id": 123456,
421
+		"wechat_id": "微信id",
422
+		"type": "清洁类型",
423
+		"area": "清洁面积",
424
+		"adress": "地址",
425
+		"contact": "联系人",
426
+		"phone": "13800138000",
427
+		"price": 12.3,
428
+		"status": 0, // 0.待处理 1.商家受理 2.待支付 3.已支付
429
+		"picture1": "/commom/picture1.jepg",
430
+		"picture2": "/commom/picture2.jepg",
431
+		"picture3": "/commom/picture3.jepg",
432
+		"picture4": "/commom/picture4.jepg",
433
+		"picture5": "/commom/picture5.jepg",
434
+		"created_at": "2018-02-16 11:10:56",
435
+		"updated_at": "2018-02-16 12:00:51"
436
+	}
437
+}
438
+```
439
+
440
+
441
+### 分页查询订单
442
+- `GET /house_clean_orders`
443
+- 参数: 无
444
+- 响应:
445
+
446
+```
447
+{
448
+   "total": 50,
449
+   "per_page": 15,
450
+   "current_page": 1,
451
+   "last_page": 4,
452
+   "first_page_url": "http://laravel.app?page=1",
453
+   "last_page_url": "http://laravel.app?page=4",
454
+   "next_page_url": "http://laravel.app?page=2",
455
+   "prev_page_url": null,
456
+   "path": "http://laravel.app",
457
+   "from": 1,
458
+   "to": 15,
459
+   "data":[ {
460
+			"id": 123456,
461
+			"wechat_id": "微信id",
462
+			"type": "清洁类型",
463
+			"area": "清洁面积",
464
+			"adress": "地址",
465
+			"contact": "联系人",
466
+			"phone": "13800138000",
467
+			"price": 12.3,
468
+			"status": 0, // 0.待处理 1.商家受理 2.待支付 3.已支付
469
+			"picture1": "/commom/picture1.jepg",
470
+			"picture2": "/commom/picture2.jepg",
471
+			"picture3": "/commom/picture3.jepg",
472
+			"picture4": "/commom/picture4.jepg",
473
+			"picture5": "/commom/picture5.jepg",
474
+			"created_at": "2018-02-16 11:10:56",
475
+			"updated_at": "2018-02-16 12:00:51"
476
+		},
477
+		...
478
+   ]
479
+}
480
+```
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+## 家电清洁订单接口
489
+### 创建/修改订单
490
+- `POST /house_appliance_clean_order/store`
491
+- 参数:
492
+
493
+参数         |  类型    |   可选               |    备注
494
+----------- |  ------  |  ------------------ |  --------
495
+id          |  integer | 	创建时空,修改时必须  |  产品id
496
+code        |  string  | 	必须               |  小程序code
497
+appliances  |  string  |   必须               |  项目, 数组形式,多个数量则出现多次
498
+address     |  string  | 	必须               |  服务地址
499
+contact     |  string  | 	必须               |  联系人
500
+phone       |  string  | 	必须               |  联系电话
501
+price       |  double  | 	可选               |  订单价格
502
+status      |  integer | 	可选,默认0          |  订单状态:0.待处理 1.商家受理 2.待支付 3.已支付
503
+
504
+- 响应:
505
+
506
+```
507
+{
508
+	"status": 0,
509
+	"message": "保存成功"
510
+}
511
+
512
+{
513
+	"status": -1,
514
+	"message": "信息不能为空!"
515
+}
516
+```
517
+
518
+### 删除订单
519
+- `DELETE /house_appliance_clean_order/delete/${id}`
520
+- 参数:无
521
+
522
+- 响应:
523
+
524
+ ```
525
+{
526
+	"status": 0,
527
+	"message": "删除成功"
528
+}
529
+
530
+{
531
+	"status": -1,
532
+	"message": "id不能为空!"
533
+}
534
+```
535
+
536
+### 获得某订单
537
+
538
+- `GET /house_appliance_clean_order/${id}`
539
+- 参数:无
540
+
541
+- 响应:
542
+
543
+ ```
544
+{
545
+	"status": 0,
546
+	"data": {
547
+		"id": 123456,
548
+		"wechat_id": "wechat_id",
549
+		"appliances": "清洁项目1, 清洁项目1, 清洁项目2, 清洁项目3",
550
+		"adress": "地址",
551
+		"contact": "联系人",
552
+		"phone": "13800138000",
553
+		"price": 12.3,
554
+		"status": 0, // 0.待处理 1.商家受理 2.待支付 3.已支付
555
+		"created_at": "2018-02-16 11:10:56",
556
+		"updated_at": "2018-02-16 12:00:51"
557
+	}
558
+}
559
+```
560
+
561
+
562
+### 分页查询订单
563
+- `GET /house_appliance_clean_orders`
564
+- 参数: 无
565
+- 响应:
566
+
567
+```
568
+{
569
+   "total": 50,
570
+   "per_page": 15,
571
+   "current_page": 1,
572
+   "last_page": 4,
573
+   "first_page_url": "http://laravel.app?page=1",
574
+   "last_page_url": "http://laravel.app?page=4",
575
+   "next_page_url": "http://laravel.app?page=2",
576
+   "prev_page_url": null,
577
+   "path": "http://laravel.app",
578
+   "from": 1,
579
+   "to": 15,
580
+   "data":[ {
581
+			"id": 123456,
582
+			"wechat_id": "wechat_id",
583
+			"appliances": "清洁项目1, 清洁项目1, 清洁项目2, 清洁项目3",
584
+			"adress": "地址",
585
+			"contact": "联系人",
586
+			"phone": "13800138000",
587
+			"price": 12.3,
588
+			"status": 0, // 0.待处理 1.商家受理 2.待支付 3.已支付
589
+			"created_at": "2018-02-16 11:10:56",
590
+			"updated_at": "2018-02-16 12:00:51"
591
+		}, 
592
+		...
593
+   ]
594
+}
595
+```

+ 3
- 0
manage-server/routes/web.php 查看文件

@@ -17,6 +17,9 @@ Route::get('/', function () {
17 17
 
18 18
 
19 19
 Route::post('/common/upload', 'CommonController@upload');
20
+Route::get('/my/orders', 'CommonController@orders');
21
+Route::post('/{order_type}/{order_id}/comment', 'CommonController@addComment');
22
+Route::get('/{order_type}/{order_id}/comments', 'CommonController@comments');
20 23
 
21 24
 Route::post('/campaign/store', 'CampaignController@store');
22 25
 Route::delete('/campaign/delete', 'CampaignController@delete');

Loading…
取消
儲存