lan = $this->request->getLan(); } /** * 首页基础数据 */ public function base(AnnouncementModel $announcement, ProductsModel $productsModel) { $resp = [ 'system_name' => __("System name"), 'banner_list' => [], 'notice_list' => [] ]; // banner $resp['banner_list'] = $announcement ->field('id,title as title,img_url,createtime') ->where('type_id', $announcement::Banner) ->where('find_in_set(:id,sub_type_id)',['id'=>11]) ->where('status', $announcement::Normal) ->where('is_show', $announcement::Normal) ->where('to_lang', $this->lan) ->limit(0,10) ->order('id DESC,weigh desc') ->select(); // 最新公告 $resp['notice_list'] = $announcement ->field('id,title as title,img_url,createtime') ->where('type_id', $announcement::Announ) ->where('status', $announcement::Normal) ->where('is_show', $announcement::Normal) ->where('to_lang', $this->lan) ->limit(0,10) ->order('id DESC,weigh desc') ->select(); //分类 $resp['type_list'] = $productsModel->where('status', $productsModel::Normal) ->field('id,'.$this->lan.'_title as title') ->order('sort desc') ->select(); $this->success('', $resp); } /** * 首页数据 */ public function all(ProductPopular $productPopular, ProductTransfer $productTransfer) { //更新库存 $productPopular::setUpdateStatus(); $resp['product_list'] = $productPopular->with('productsList') ->where('product_popular.status', '<', $productPopular::Stop) ->order('weigh desc,start_time asc')->select(); //$this->pageSize) $this->success('', $resp); } /** * 热销详情 * @param int $uid * @param string $fee * @param string $txHsh * @return void */ public function getPopularInfo(ProductPopular $productPopular, ProductOrder $productOrder) { try { $ids = $this->request->post('ids/d', 0); $product_id = $this->request->post('product_id/d', 0); if(empty($ids)) throw new Exception(__("Parameter error")); $times = array(); $order = array(); //详情 $info = $productPopular::getProductInfo($product_id, $ids, $this->lan); if(!empty($info)) { $times = $productPopular ->where('product_id', $info['product_id']) ->field('title,price, start_time, end_time, status') ->order('weigh desc')->limit(10)->select(); } if(!empty($info)) { $order = $productOrder->alias('a') ->join("user u", "a.user_id = u.id", "left") ->where('order_id', $ids)->field('u.address, u.avatar, a.create_time') ->order('a.id desc')->limit(10)->select(); } } catch (Exception $e) { $this->error( $e->getMessage()); } $this->success('', compact('info', 'times', 'order')); } /** * 获取地址 * @return void * @throws Exception */ public function getProductAddres(ProductArea $productarea) { $search = $this->request->post('search/s', ''); $pid = $this->request->post('product_id/d', 0); if(empty($pid)) $this->error(__("Parameter error")); $map = array(); if(!empty($search)) $map['address'] = ['like', '%'.$search.'%']; $list = $productarea ->field('id,province,city,area,county,address') ->where('product_id', $pid) ->where('status', $productarea::Normal) ->where($map) ->paginate($this->pageSize); // 提交事务 $this->success('', $list); } //首页轮播图 public function getBanner() { $this->success('ok', config('best_cha')); } }