request->input('market_id', -1); $banners = $this->bannerService->all(Banner::TYPE_APPLET_INDEX, $marketId); $categories = $this->categoryService->allForAppletIndex(); $activity = $this->activityService->allForAppletIndex(env('APPLET_INDEX_ACTIVITY_TYPE'), $marketId); $tabs = $this->tabsService->allForAppletIndex(); return $this->success([ 'banners' => $banners, 'categories' => $categories, 'activity' => ['type' => ActivityType::FLASH_SALE, 'goods' => $activity], 'tabs' => $tabs, ]); } /** * 用户首页,我的页面 * 1、用户信息,id、昵称、名字、头像 * 2、收藏、红包、积分 * 3、badge角标,待付款、待收货、已完成、售后, SSDB维护 * 4、为你推荐的商品列表 * @param UserIndexRequest $request * @return ResponseInterface */ public function userIndex(UserIndexRequest $request) { $params = $request->validated(); $data['user'] = $this->userInfoService->detail($params['user_id']); $store_info = $this->userInfoService->getStoreByUID($params['user_id']); $sp_info = $this->userInfoService->getServicePersonnelByUID($params['user_id']); $data['user']['store_info'] = $store_info; $data['user']['sp_info'] = $sp_info; $roles = []; //角色判断 if($store_info){ $roles[] = [ 'key'=>'store', 'title'=>'商家', 'color'=>'#0091FF', 'data'=>$store_info, ]; } if($sp_info){ $roles[] = [ 'key'=>'sp', 'title'=>'服务', 'color'=>'#0091FF', 'data'=>$sp_info, ]; } $data['user']['collection_count'] = $this->collectStoreService->countByUser($params['user_id']); $data['user']['coupon_count'] = $this->couponRecService->countAvailableByUser($params['user_id']); $data['user']['role'] = $roles; $data['badge'] = $this->badgeService->allByUserOrder($params['user_id']); $data['block'] = $this->userCenterBlockService->all($roles); return $this->success($data); } /** * 商家入口详情 */ public function storeIndex(StoreIndexRequest $request) { $params = $request->validated(); //每日 每周 每月 开始结束时间 $dayStartTime = strtotime(date('Y-m-d'.' 00:00:00')); $dayEndTime = strtotime(date('Y-m-d'.' 23:59:59')); $weekStartTime = mktime(0,0,0,date('m'),date('d')-date('N')+1,date('y')); //$weekEndTime = mktime(23,59,59,date('m'),date('d')-date('N')+7,date('Y')); $monthStartTime = mktime(0,0,0,date('m'),1,date('Y')); //$monthEndTime = mktime(23,59,59,date('m'),date('t'),date('Y')); $data['detail'] = $this->storeService->detail($params['store_id']); //当面付 and 线上订单个数统计 $data['order_online']['count'] = $this->orderStatisticsService->countOrder($params['store_id'],OrderType::ONLINE,$dayStartTime,$dayEndTime); $data['order_offline']['count'] = $this->orderStatisticsService->countOrder($params['store_id'],OrderType::OFFLINE,$dayStartTime,$dayEndTime); //统计订单金额 $type = [ FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP, FinancialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP ]; $data['order_online']['total'] = 0; $data['order_offline']['total'] = 0; $revenueByOrder = $this->revenueListService->getRevenueByUser($params['user_id'],$type,$dayStartTime,$dayEndTime); foreach ($revenueByOrder as $order){ if($order['money_type'] == FinancialRecord::MONEY_TYPE_STORE_OL_ORDER_COMP){ //线上订单 $data['order_online']['total'] = bcadd($data['order_online']['total'],$order['money'],2); }else if($order->money_type == FinancialRecord::MONEY_TYPE_STORE_OFL_ORDER_COMP){ //线下订单 $data['order_offline']['total'] = bcadd($data['order_online']['total'],$order['money'],2); } } //统计新增用户 无法筛选时间 所以和订单分开查询 $revenueByNewUsers = $this->revenueListService->getRevenueByUser($params['user_id'],[FinancialRecord::MONEY_TYPE_STORE_PLAT_NEW_USER]); $data['new_user'] = [ 'day' => 0, 'week' => 0, 'month' => 0, 'all' => 0 ]; foreach ($revenueByNewUsers as $newUser) { if($newUser['created_at'] > $dayStartTime){ $data['new_user']['day']++; } if($newUser['created_at'] > $weekStartTime){ $data['new_user']['week']++; } if($newUser['created_at'] > $monthStartTime){ $data['new_user']['month']++; } $data['new_user']['all']++; } $data['badge'] = $this->badgeService->allByStoreOrder($params['store_id']); return $this->success($data); } /** * 关于懒族 * about lanzu */ public function aboutLanzu() { $data = [ [ 'id' => 1, 'title' => '关于懒族', 'sub_title' => '懒族生活678', 'path' => 'https://www.baidu.com/s?wd=%E6%87%92%E6%97%8F%E7%94%9F%E6%B4%BB', 'path_type' => 'webview' ], [ 'id' => 1, 'title' => '隐私政策', 'sub_title' => '隐私政策123', 'path' => 'https://www.baidu.com/s?wd=%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96', 'path_type' => 'webview' ] ]; return $this->success(['data' => $data]); } /** * 市场 */ public function marketInfo() { $marketId = $this->request->input('market_id', 0); return $this->success(['market' => Market::query()->find($marketId)]); } }