Sfoglia il codice sorgente

新增自定义字段接口

chenxiqiang 6 anni fa
parent
commit
d7ebddc038

+ 9
- 171
manage-server/app/Http/Controllers/ClassifyController.php Vedi File

@@ -77,181 +77,13 @@ class ClassifyController extends Controller
77 77
     public function get(Request $request,  $id)
78 78
     {
79 79
         $id = $request->route("id");
80
-        $fields_josn = "";
81
-        if($id == 6) {
82
-            $fields_josn ='{
83
-                "id": 6,
84
-                "api": "maternity_matron_order/store",
85
-                "fields": [
86
-                    {
87
-                        "name": "level",
88
-                        "name_cn": "一价全包",
89
-                        "input_group": [
90
-                            {
91
-                                "type": "radio",
92
-                                "value": "8800(初级月嫂)"
93
-                            },   
94
-                            {
95
-                                "type": "radio",
96
-                                "value": "9800(普通月嫂)"
97
-                            },   
98
-                            {
99
-                                "type": "radio",
100
-                                "value": "12800(高级月嫂)"
101
-                            },   
102
-                            {
103
-                                "type": "radio",
104
-                                "value": "15800(金牌月嫂)"
105
-                            },   
106
-                            {
107
-                                "type": "radio",
108
-                                "value": "18800(特级月嫂)"
109
-                            }
110
-                        ]
111
-                    }
112
-                ]
113
-            }';
114
-        } else {
115
-            $fields_josn = '{
116
-                "id": 7,
117
-                "api": "housekeeper_order/store",
118
-                "fields": [
119
-                    {
120
-                        "name": "contents",
121
-                        "name_cn": "服务内容",
122
-                        "input_group": [
123
-                            {
124
-                                "type": "radio",
125
-                                "value": "保洁"
126
-                            },   
127
-                            {
128
-                                "type": "radio",
129
-                                "value": "婴儿看护"
130
-                            },   
131
-                            {
132
-                                "type": "radio",
133
-                                "value": "老人看护"
134
-                            },   
135
-                            {
136
-                                "type": "radio",
137
-                                "value": "全护理老人"
138
-                            },   
139
-                            {
140
-                                "type": "radio",
141
-                                "value": "空调清洗"
142
-                            },   
143
-                            {
144
-                                "type": "radio",
145
-                                "value": "冰箱清洗"
146
-                            },   
147
-                            {
148
-                                "type": "radio",
149
-                                "value": "抽油烟机清洗"
150
-                            },   
151
-                            {
152
-                                "type": "radio",
153
-                                "value": "家庭除螨"
154
-                            },   
155
-                            {
156
-                                "type": "radio",
157
-                                "value": "开荒清洁"
158
-                            },   
159
-                            {
160
-                                "type": "radio",
161
-                                "value": "催乳"
162
-                            },   
163
-                            {
164
-                                "type": "radio",
165
-                                "value": "产后康复"
166
-                            }
167
-                        ]
168
-                    },
169
-                    {
170
-                        "name": "people_num",
171
-                        "name_cn": "人口数量",
172
-                        "input_group": [
173
-                            {
174
-                                "type": "radio",
175
-                                "value": "1-2人"
176
-                            },   
177
-                            {
178
-                                "type": "radio",
179
-                                "value": "3-4人"
180
-                            },   
181
-                            {
182
-                                "type": "radio",
183
-                                "value": "5-6人"
184
-                            },   
185
-                            {
186
-                                "type": "radio",
187
-                                "value": "6人以上"
188
-                            }
189
-                        ]
190
-                    },
191
-                    {
192
-                        "name": "area",
193
-                        "name_cn": "房屋面积",
194
-                        "input_group": [
195
-                            {
196
-                                "type": "radio",
197
-                                "value": "60平以下"
198
-                            },   
199
-                            {
200
-                                "type": "radio",
201
-                                "value": "60-120平"
202
-                            },   
203
-                            {
204
-                                "type": "radio",
205
-                                "value": "120-160平"
206
-                            },   
207
-                            {
208
-                                "type": "radio",
209
-                                "value": "160-200平"
210
-                            },   
211
-                            {
212
-                                "type": "radio",
213
-                                "value": "200平以上"
214
-                            }
215
-                        ]
216
-                    },
217
-                    {
218
-                        "name": "server_time",
219
-                        "name_cn": "服务时间",
220
-                        "input_group": [
221
-                            {
222
-                                "type": "radio",
223
-                                "value": "全白天"
224
-                            },   
225
-                            {
226
-                                "type": "radio",
227
-                                "value": "住家"
228
-                            }
229
-                        ]
230
-                    },
231
-                    {
232
-                        "name": "rest",
233
-                        "name_cn": "休息安排",
234
-                        "input_group": [
235
-                            {
236
-                                "type": "radio",
237
-                                "value": "每周单休"
238
-                            },   
239
-                            {
240
-                                "type": "radio",
241
-                                "value": "每周双休"
242
-                            }
243
-                        ]
244
-                    }
245
-                ]
246
-            }';
247
-        }
248 80
 
249
-        $data = json_decode($fields_josn, true);
250
-        $data["id"] = $id;
81
+        $data = [];
251 82
         if ($id) {
252 83
             $record = Classify::find($id);
253 84
             if ($record) {
254
-
85
+                $data["api"] = $record->api;
86
+                $data["fields"] = json_decode($record->fields_json, true);
255 87
                 return Response()->json([
256 88
                     "status" => 0,
257 89
                     "data" => [
@@ -329,10 +161,15 @@ class ClassifyController extends Controller
329 161
         $content = $request->input('content');
330 162
         $photo = $request->input('photo');
331 163
         $location = $request->input('location');
164
+        $fields_json = $request->input('fields_json');
165
+        $api = $request->input('api');
332 166
         if ($id) {
333 167
             $classify = Classify::find($id);
334 168
         } else {
335 169
             $classify = new Classify;
170
+            if(!$api) {
171
+                $classify->api = "option_order/store";
172
+            }
336 173
         }
337 174
         if ($pid && $name && $info && $summary && $server && $content && $photo && $location) {
338 175
             $classify->pid = $pid;
@@ -343,6 +180,7 @@ class ClassifyController extends Controller
343 180
             $classify->content = $content;
344 181
             $classify->photo = $photo;
345 182
             $classify->location = $location;
183
+            $classify->fields_json = $fields_json;
346 184
             $classify->save();
347 185
             return Response()->json([
348 186
                 "status" => 0,

+ 3
- 10
manage-server/app/Http/Controllers/OptionOrderController.php Vedi File

@@ -25,7 +25,7 @@ class OptionOrderController extends Controller
25 25
 
26 26
         $wechat_id = $request->header("openid");
27 27
 
28
-        $option_ids = $request->input("options");
28
+        $options = $request->input("options");
29 29
         $id = $request->input("id");
30 30
         $address = $request->input('address');
31 31
         $contact = $request->input('contact');
@@ -36,13 +36,7 @@ class OptionOrderController extends Controller
36 36
         $status = $request->input('status');
37 37
         $photo = $request->input('photo');
38 38
 
39
-        if($option_ids && $address && $contact && $phone && $classify) {
40
-            $kvs = [];
41
-            foreach ($option_ids as $option_id) {
42
-                $option_value = OptionValue::with("optionKey")->find($option_id);
43
-                $kvs[$option_value->optionKey->key] = $option_value->value;
44
-            }
45
-
39
+        if($options && $address && $contact && $phone && $classify) {
46 40
             if(!$id) {
47 41
                 $option_order = new OptionOrder;
48 42
                 $option_order->status = 0;
@@ -57,7 +51,7 @@ class OptionOrderController extends Controller
57 51
             $option_order->phone = $phone;
58 52
             $option_order->notes = $notes;
59 53
             $option_order->classify = $classify;
60
-            $option_order->options = json_encode($kvs, JSON_UNESCAPED_UNICODE);
54
+            $option_order->options = json_encode($options, JSON_UNESCAPED_UNICODE);
61 55
             if($classify) {
62 56
                 $classify2 = $this->classify_name[$classify]->name;
63 57
                 $pid = $this->classify_name[$classify]->pid;
@@ -78,7 +72,6 @@ class OptionOrderController extends Controller
78 72
             return Response()->json([
79 73
                 "status" => -1,
80 74
                 "message" => "信息不能为空!",
81
-                "options" => $option_ids
82 75
             ]);
83 76
         }
84 77
     }

+ 2
- 0
manage-server/app/Models/Classify.php Vedi File

@@ -15,6 +15,8 @@ class Classify extends Model
15 15
         'content', // 服务详情
16 16
         'photo', // 首页显示的
17 17
         'location', // 显示位置
18
+        'fields_json', // 自定义字段
19
+        'api', // 接口字段
18 20
     ];
19 21
 
20 22
     protected $children = [];

+ 2
- 0
manage-server/database/migrations/2018_08_20_075456_create_classifies_table.php Vedi File

@@ -24,6 +24,8 @@ class CreateClassifiesTable extends Migration
24 24
             $table->string('server');
25 25
             $table->string('photo');
26 26
             $table->string('location');
27
+            $table->text('fields_json');
28
+            $table->string('api');
27 29
         });
28 30
     }
29 31
 

+ 1
- 1
manage-server/routes/web.php Vedi File

@@ -35,7 +35,7 @@ Route::middleware(['manage.token'])->group(function () {
35 35
     Route::get('/classify/{id}', 'ClassifyController@get');
36 36
     Route::get('/{order_type}/comments', 'CommonController@type_comments');
37 37
     Route::post('/{order_type}/status', 'CommonController@status');
38
-    Route::post('/{order_type}/price', 'CommonController@price');
38
+    Route::post('/{order_type}/price', 'CommonController@price')->where('order_type', '^[^r]');
39 39
     Route::get('/{order_type}/{id}', 'CommonController@get')->where('id', '[0-9]+');
40 40
     Route::delete('/{order_type}/{id}', 'CommonController@delete')->where('id', '[0-9]+');
41 41
 

Loading…
Annulla
Salva