|
@@ -140,4 +140,144 @@ class CoachController extends RestBaseController |
|
@@ -140,4 +140,144 @@ class CoachController extends RestBaseController |
140
|
|
140
|
|
141
|
$this->success("获取数据成功", ['data'=>$new_arr,'coach'=>$coach]);
|
141
|
$this->success("获取数据成功", ['data'=>$new_arr,'coach'=>$coach]);
|
142
|
}
|
142
|
}
|
|
|
143
|
+
|
|
|
144
|
+
|
|
|
145
|
+ /**
|
|
|
146
|
+ * @title 场所详情
|
|
|
147
|
+ * @description 场所详情接口
|
|
|
148
|
+ * @author Pan Haowen
|
|
|
149
|
+ * @url /home/coach/room
|
|
|
150
|
+ * @method POST
|
|
|
151
|
+ * @header name:XX-Token require:1 default: desc:token
|
|
|
152
|
+ * @param name:room_id type:int require:1 desc:场所id
|
|
|
153
|
+ * @param name:time type:int require:0 desc:筛选课程时间戳
|
|
|
154
|
+ * @return room:场所详情
|
|
|
155
|
+ * @return class:该场所课程
|
|
|
156
|
+ */
|
|
|
157
|
+ public function room()
|
|
|
158
|
+ {
|
|
|
159
|
+ $userId = $this->getUserId();
|
|
|
160
|
+ $param = $this->request->param();
|
|
|
161
|
+
|
|
|
162
|
+ $data['room'] = Db::name('room')->where('id', $param['room_id'])->find();
|
|
|
163
|
+ //图片处理
|
|
|
164
|
+ $data['room']['thumbnail'] = cmf_get_image_preview_url($data['room']['thumbnail']);
|
|
|
165
|
+
|
|
|
166
|
+ //距离计算
|
|
|
167
|
+ $distance=new ToolsService();
|
|
|
168
|
+ $user = Db::name('user')->where('id', $userId)->find();
|
|
|
169
|
+ $dis=$distance->distance($user['jing'],$user['wei'],$data['room']['lng'],$data['room']['lat']);
|
|
|
170
|
+ if($dis<1000){
|
|
|
171
|
+ $dis=floor($dis).'m';
|
|
|
172
|
+ }else{
|
|
|
173
|
+ $dis=round(($dis/1000),1).'km';
|
|
|
174
|
+ }
|
|
|
175
|
+ $data['room']['distance'] = $dis;
|
|
|
176
|
+
|
|
|
177
|
+ //根据时间计算课程
|
|
|
178
|
+ $where['c.delete_time'] = null;
|
|
|
179
|
+ $where['c.status']=3;
|
|
|
180
|
+ $where['p.delete_time'] = null;
|
|
|
181
|
+ $where['c.room_id'] = $param['room_id'];
|
|
|
182
|
+ if (!empty($param['time'])) {
|
|
|
183
|
+ $time1=$param['time'];
|
|
|
184
|
+ $time2=strtotime('+1 month',$param['time']);
|
|
|
185
|
+ $where['c.start_time'] = [['>= time',intval($time1) ], ['<= time',$time2]];
|
|
|
186
|
+ }
|
|
|
187
|
+ else {
|
|
|
188
|
+ $where['c.start_time'] = [['>= time', strtotime('+1 month', strtotime(date('Y-m', time())))], ['<= time', strtotime('+2 month', strtotime(date('Y-m', time())))]];
|
|
|
189
|
+ }
|
|
|
190
|
+ $data['class'] = Db::name('class')
|
|
|
191
|
+ ->alias('c')
|
|
|
192
|
+ ->join('product p', 'c.product_id=p.id')
|
|
|
193
|
+ ->where($where)
|
|
|
194
|
+// ->where(['c.start_time'=>[['>= time',intval($param['time'])], ['<= time',$time2]]])
|
|
|
195
|
+ ->group('c.product_id')
|
|
|
196
|
+ ->field('p.*,c.room_id,count(*) as count')
|
|
|
197
|
+ ->select()
|
|
|
198
|
+ ->each(function ($item) {
|
|
|
199
|
+ $item['thumbnail'] = cmf_get_image_preview_url($item['thumbnail']);
|
|
|
200
|
+ return $item;
|
|
|
201
|
+ });
|
|
|
202
|
+
|
|
|
203
|
+ $this->success("获取数据成功", $data);
|
|
|
204
|
+ }
|
|
|
205
|
+
|
|
|
206
|
+
|
|
|
207
|
+ /**
|
|
|
208
|
+ * @title 计划产品
|
|
|
209
|
+ * @description 计划产品
|
|
|
210
|
+ * @author Pan Haowen
|
|
|
211
|
+ * @url /home/coach/Class
|
|
|
212
|
+ * @method POST
|
|
|
213
|
+ * @header name:XX-Token require:1 default: desc:token
|
|
|
214
|
+ * @param name:product_id type:int require:1 desc:产品id
|
|
|
215
|
+ * @param name:room_id type:int require:1 desc:场所id
|
|
|
216
|
+ * @param name:time type:int require:0 desc:筛选课程时间戳
|
|
|
217
|
+ * @return room:场所信息
|
|
|
218
|
+ * @return product:产品信息
|
|
|
219
|
+ * @return tuan:团课教程
|
|
|
220
|
+ * @return si:私课教程
|
|
|
221
|
+ */
|
|
|
222
|
+ public function Class()
|
|
|
223
|
+ {
|
|
|
224
|
+ $userId = $this->getUserId();
|
|
|
225
|
+ $param = $this->request->param();
|
|
|
226
|
+ //场所信息
|
|
|
227
|
+ $data['room'] = Db::name('room')->where('id', $param['room_id'])->field('id,name,lat,lng,location')->find();
|
|
|
228
|
+ $distance=new ToolsService();
|
|
|
229
|
+ $user = Db::name('user')->where('id', $userId)->find();
|
|
|
230
|
+ $dis=$distance->distance($user['jing'],$user['wei'],$data['room']['lng'],$data['room']['lat']);
|
|
|
231
|
+ if($dis<1000){
|
|
|
232
|
+ $dis=floor($dis).'m';
|
|
|
233
|
+ }else{
|
|
|
234
|
+ $dis=round(($dis/1000),1).'km';
|
|
|
235
|
+ }
|
|
|
236
|
+ $data['room']['distance'] = $dis;
|
|
|
237
|
+
|
|
|
238
|
+ //产品信息
|
|
|
239
|
+ $data['product'] = Db::name('product')->where('id', $param['product_id'])->find();
|
|
|
240
|
+ $data['product']['thumbnail'] = cmf_get_image_preview_url($data['product']['thumbnail']);
|
|
|
241
|
+
|
|
|
242
|
+
|
|
|
243
|
+ //根据时间计算课程
|
|
|
244
|
+ $where['delete_time'] = null;
|
|
|
245
|
+ $where['room_id'] = $param['room_id'];
|
|
|
246
|
+ $where['product_id'] = $param['product_id'];
|
|
|
247
|
+ if (!empty($param['time'])) {
|
|
|
248
|
+ $where['start_time'] = [['>= time', intval($param['time'])], ['<= time', strtotime('+1 month', $param['time'])]];
|
|
|
249
|
+ } else {
|
|
|
250
|
+ $where['start_time'] = [['>= time', strtotime('+1 month', strtotime(date('Y-m', time())))], ['<= time', strtotime('+2 month', strtotime(date('Y-m', time())))]];
|
|
|
251
|
+ }
|
|
|
252
|
+ //团教课程
|
|
|
253
|
+ $data['tuan'] = Db::name('class')
|
|
|
254
|
+ ->where($where)
|
|
|
255
|
+ ->where(['type'=>1,'status'=>3])
|
|
|
256
|
+ ->limit(2)
|
|
|
257
|
+ ->select()
|
|
|
258
|
+ ->each(function ($item) {
|
|
|
259
|
+ $item['avatar'] = Db::name('user_class_apply')->where(['class_id' => $item['id'], 'status' => 1])->limit(4)->select()->each(function ($item2) {
|
|
|
260
|
+ $user = Db::name('user')->where('id', $item2['user_id'])->find();
|
|
|
261
|
+ $item2['avatar'] = cmf_get_image_preview_url($user['avatar']);
|
|
|
262
|
+ $item2['user_name'] = $user['user_nickname'];
|
|
|
263
|
+ return $item2;
|
|
|
264
|
+ });
|
|
|
265
|
+ return $item;
|
|
|
266
|
+ });
|
|
|
267
|
+
|
|
|
268
|
+ //私教课程
|
|
|
269
|
+ $data['si'] = Db::name('class')
|
|
|
270
|
+ ->where($where)
|
|
|
271
|
+ ->where(['type'=>2,'status'=>3])
|
|
|
272
|
+ ->limit(2)
|
|
|
273
|
+ ->select()
|
|
|
274
|
+ ->each(function ($item) {
|
|
|
275
|
+ $coach_id = Db::name('coach_class_apply')->where(['class_id' => $item['id'], 'status' => 1])->find()['coach_id'];
|
|
|
276
|
+ $coach = Db::name('coach')->where('id', $coach_id)->find();
|
|
|
277
|
+ $item['avatar'] = cmf_get_image_preview_url($coach['avatar']);
|
|
|
278
|
+ $item['coach_name'] = $coach['name'];
|
|
|
279
|
+ return $item;
|
|
|
280
|
+ });
|
|
|
281
|
+ $this->success("获取数据成功", $data);
|
|
|
282
|
+ }
|
143
|
} |
283
|
} |