|
@@ -12,6 +12,7 @@ use App\Models\UserMessage;
|
12
|
12
|
use App\Models\Special;
|
13
|
13
|
use App\Models\News;
|
14
|
14
|
use App\Models\NewsCategory;
|
|
15
|
+use App\Models\CollectReceipt;
|
15
|
16
|
use Illuminate\Http\Request;
|
16
|
17
|
use Solr;
|
17
|
18
|
use DB;
|
|
@@ -226,7 +227,7 @@ class FeaturesController extends BaseController
|
226
|
227
|
foreach($data as $key=>$value){
|
227
|
228
|
$data[$key]['url']=config('constants.HOST_URL').$value['url'];
|
228
|
229
|
}
|
229
|
|
- $json_menu_idarr=Special::whereNotIn('title',['上午','中午','下午'])->where('status',1)->pluck('contain_recipes');
|
|
230
|
+ $json_menu_idarr=Special::whereNotIn('title',['上午','中午','下午'])->where('status',1)->where('releaseTime','<',$today)->pluck('contain_recipes');
|
230
|
231
|
$json_menu_idarr=json_decode(json_encode($json_menu_idarr),true);
|
231
|
232
|
$initArr=array();
|
232
|
233
|
foreach($json_menu_idarr as $item){
|
|
@@ -236,11 +237,25 @@ class FeaturesController extends BaseController
|
236
|
237
|
}
|
237
|
238
|
$initArr=array_unique($initArr);
|
238
|
239
|
$menuAll=DB::table('menu')->whereIn('id',$initArr)->where('status',1)->get();
|
|
240
|
+
|
|
241
|
+ $readArr=Menu::getReadNum($initArr);
|
|
242
|
+ $discountArr=Menu::getCollectNum($initArr);
|
|
243
|
+
|
239
|
244
|
$menuAll=json_decode(json_encode($menuAll),true);
|
240
|
245
|
foreach($menuAll as $key=>$value){
|
241
|
246
|
if(!$this->startsWith($value['url'],'http') && $value['url'] !='None' && $value['url']!=''){
|
242
|
247
|
$menuAll[$key]['url']=config('constants.HOST_URL').$value['url'];
|
243
|
248
|
}
|
|
249
|
+ if(array_key_exists($value['id'],$readArr)){
|
|
250
|
+ $menuAll[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000))+$readArr[$value['id']];
|
|
251
|
+ }else{
|
|
252
|
+ $menuAll[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000));
|
|
253
|
+ }
|
|
254
|
+ if(array_key_exists($value['id'],$discountArr)){
|
|
255
|
+ $menuAll[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000))+$discountArr[$value['id']];
|
|
256
|
+ }else{
|
|
257
|
+ $menuAll[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000));
|
|
258
|
+ }
|
244
|
259
|
}
|
245
|
260
|
$middleArr=array();
|
246
|
261
|
foreach($menuAll as $item){
|
|
@@ -257,6 +272,10 @@ class FeaturesController extends BaseController
|
257
|
272
|
}
|
258
|
273
|
public function theLastRecipes(Request $request){
|
259
|
274
|
$data=Menu::where('status',1)->orderBy('created_at','desc')->limit(50)->get();
|
|
275
|
+ $initArr=Menu::where('status',1)->orderBy('created_at','desc')->limit(50)->pluck('menu_id');
|
|
276
|
+ $initArr=json_decode(json_encode($initArr),true);
|
|
277
|
+ $readArr=Menu::getReadNum($initArr);
|
|
278
|
+ $discountArr=Menu::getCollectNum($initArr);
|
260
|
279
|
if (!$data) {
|
261
|
280
|
return $this->response->array(self::returnValue(['data' => 'Database error'], 9999));
|
262
|
281
|
}
|
|
@@ -265,6 +284,16 @@ class FeaturesController extends BaseController
|
265
|
284
|
if(!$this->startsWith($value['url'],'http') && $value['url'] !='None' && $value['url']!=''){
|
266
|
285
|
$data[$key]['url']=config('constants.HOST_URL').$value['url'];
|
267
|
286
|
}
|
|
287
|
+ if(array_key_exists($value['id'],$readArr)){
|
|
288
|
+ $data[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000))+$readArr[$value['id']];
|
|
289
|
+ }else{
|
|
290
|
+ $data[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000));
|
|
291
|
+ }
|
|
292
|
+ if(array_key_exists($value['id'],$discountArr)){
|
|
293
|
+ $data[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000))+$discountArr[$value['id']];
|
|
294
|
+ }else{
|
|
295
|
+ $data[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000));
|
|
296
|
+ }
|
268
|
297
|
}
|
269
|
298
|
return $this->response->array(self::returnValue(['data' => $data], 200));
|
270
|
299
|
}
|
|
@@ -287,11 +316,23 @@ class FeaturesController extends BaseController
|
287
|
316
|
$idArr=explode(',',$special['contain_recipes']);
|
288
|
317
|
}
|
289
|
318
|
$menuList=Menu::whereIn('id',$idArr)->get();
|
|
319
|
+ $readArr=Menu::getReadNum($idArr);
|
|
320
|
+ $discountArr=Menu::getCollectNum($idArr);
|
290
|
321
|
$menuList=json_decode(json_encode($menuList),true);
|
291
|
322
|
foreach($menuList as $key=>$value){
|
292
|
323
|
if(!$this->startsWith($value['url'],'http') && $value['url'] !='None' && $value['url']!=''){
|
293
|
324
|
$menuList[$key]['url']=config('constants.HOST_URL').$value['url'];
|
294
|
325
|
}
|
|
326
|
+ if(array_key_exists($value['id'],$readArr)){
|
|
327
|
+ $menuList[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000))+$readArr[$value['id']];
|
|
328
|
+ }else{
|
|
329
|
+ $menuList[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000));
|
|
330
|
+ }
|
|
331
|
+ if(array_key_exists($value['id'],$discountArr)){
|
|
332
|
+ $menuList[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000))+$discountArr[$value['id']];
|
|
333
|
+ }else{
|
|
334
|
+ $menuList[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000));
|
|
335
|
+ }
|
295
|
336
|
}
|
296
|
337
|
return $this->response->array(self::returnValue(['data' => $menuList], 200));
|
297
|
338
|
}
|
|
@@ -309,6 +350,26 @@ class FeaturesController extends BaseController
|
309
|
350
|
$init[$origin[0]]=$origin[1];
|
310
|
351
|
}
|
311
|
352
|
$menu['ingredients']=$init;
|
|
353
|
+ $token = $request->headers->get('token');
|
|
354
|
+ if($token==''){
|
|
355
|
+ $menu['is_collect']=0;
|
|
356
|
+ }else{
|
|
357
|
+ $user = DB::table('users')->where('token', $token)->first();
|
|
358
|
+ $tokendata= !empty($user) ? $user : null;
|
|
359
|
+ if(empty($tokendata) || ($token!=$tokendata->token && (($tokendata->last_login_time - 30 *86400) > time()))) {
|
|
360
|
+ $menu['is_collect']=0;
|
|
361
|
+ }else{
|
|
362
|
+ $user_id = Menu::getUserId($token);
|
|
363
|
+ //查询是否收藏过该商品 收藏过 - 取消收藏 ; 未收藏 - 进行收藏操作
|
|
364
|
+ $is_collect = Menu::isCollectTicket($user_id,$id);
|
|
365
|
+ if ($is_collect ==1 ){
|
|
366
|
+ $menu['is_collect']=1;
|
|
367
|
+ }else{
|
|
368
|
+ //未收藏该商品,进行收藏
|
|
369
|
+ $menu['is_collect']=0;
|
|
370
|
+ }
|
|
371
|
+ }
|
|
372
|
+ }
|
312
|
373
|
$menuDetail=DB::table('menu_step')->where('menu_id',$id)->get();
|
313
|
374
|
$menuDetail=json_decode(json_encode($menuDetail),true);
|
314
|
375
|
foreach($menuDetail as $key=>$value){
|
|
@@ -346,4 +407,65 @@ class FeaturesController extends BaseController
|
346
|
407
|
$articleDetail['content'] = str_replace(array("/ueditor/php/upload/"), config('constants.HOST_URL')."/ueditor/php/upload/", $articleDetail['content']);
|
347
|
408
|
return $this->response->array(self::returnValue(['data' => $articleDetail], 200));
|
348
|
409
|
}
|
|
410
|
+
|
|
411
|
+ public function collectRecipes(Request $request){
|
|
412
|
+ $token=$request->header('token');
|
|
413
|
+ $user=DB::table('user')->where('token',$token)->first();
|
|
414
|
+ if(count($user)){
|
|
415
|
+ $data['user_id']=$user('user_id');
|
|
416
|
+ }else{
|
|
417
|
+ return $this->response->array(self::returnValue(['data' => 'user is not found'], 400));
|
|
418
|
+ }
|
|
419
|
+ $data['menu_id']=$request->input('menu_id');
|
|
420
|
+ $data['create_time']=date("Y-m-d H:i:s",time());
|
|
421
|
+ $data=DB::table('collect_recipes')->where('user_id',$data['user_id'])->where('menu_id',$data['menu_id'])->first();
|
|
422
|
+ if($data){
|
|
423
|
+ if($data['status']==1){
|
|
424
|
+ $status=0;
|
|
425
|
+ }else{
|
|
426
|
+ $status=1;
|
|
427
|
+ }
|
|
428
|
+ $res=DB::table('collect_recipes')->where('user_id',$data['user_id'])->where('menu_id',$data['menu_id'])->update(['status'=>$status,'create_time'=>$data['create_time']]);
|
|
429
|
+ }else{
|
|
430
|
+ DB::table('collect_recipes')->insert($data);
|
|
431
|
+ }
|
|
432
|
+ return $this->response->array(self::returnValue(['data' => '收藏成功'], 200));
|
|
433
|
+ }
|
|
434
|
+
|
|
435
|
+ public function receiptPersonList(Request $request){
|
|
436
|
+ $user_id=$request->input('user_id');
|
|
437
|
+ $list=DB::table('collect_recipes')->where('user_id',$user_id)->pluck('menu_id');
|
|
438
|
+ $menuList=Menu::whereIn('id',$list)->get();
|
|
439
|
+ $readArr=Menu::getReadNum($list);
|
|
440
|
+ $discountArr=Menu::getCollectNum($list);
|
|
441
|
+ $menuList=json_decode(json_encode($menuList),true);
|
|
442
|
+ foreach($menuList as $key=>$value){
|
|
443
|
+ if(!$this->startsWith($value['url'],'http') && $value['url'] !='None' && $value['url']!=''){
|
|
444
|
+ $menuList[$key]['url']=config('constants.HOST_URL').$value['url'];
|
|
445
|
+ }
|
|
446
|
+ if(array_key_exists($value['id'],$readArr)){
|
|
447
|
+ $menuList[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000))+$readArr[$value['id']];
|
|
448
|
+ }else{
|
|
449
|
+ $menuList[$key]['readingVolume']=intval(abs(crc32($value['id'])/1000000));
|
|
450
|
+ }
|
|
451
|
+ if(array_key_exists($value['id'],$discountArr)){
|
|
452
|
+ $menuList[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000))+$discountArr[$value['id']];
|
|
453
|
+ }else{
|
|
454
|
+ $menuList[$key]['collectVolume']=intval(abs(crc32($value['id'])/100000000));
|
|
455
|
+ }
|
|
456
|
+ }
|
|
457
|
+ return $this->response->array(self::returnValue(['data' => $menuList], 200));
|
|
458
|
+ }
|
|
459
|
+
|
|
460
|
+ public function menuRead(Request $request){
|
|
461
|
+ $menu_id=$request->input('menu_id');
|
|
462
|
+ $res=DB::table('menu_read_num')->where('menu_id',$menu_id)->first();
|
|
463
|
+ if($res){
|
|
464
|
+ $result=DB::table('menu_read_num')->where('menu_id',$menu_id)->increment('num');
|
|
465
|
+ }else{
|
|
466
|
+ $data['menu_id']=$menu_id;
|
|
467
|
+ $result=DB::table('menu_read_num')->insert($data);
|
|
468
|
+ }
|
|
469
|
+ return $this->response->array(self::returnValue(['data' => '阅读成功'], 200));
|
|
470
|
+ }
|
349
|
471
|
}
|