merchantId); return $this->render('goods',['recommend' => $recommendGoods]); } /** * 将商品推荐到首页 */ public function actionPutGoodsToIndex() { $get = Yii::$app->request->get(); $id = isset($get['id']) ? $get['id'] : 0; $goods = xhGoodsService::getById($id); if($goods['merchantId'] != $this->merchantId){ util::failInfo(); } $recommend = xhRecommendService::getByMerchantId($this->merchantId); $goods = $recommend['goods']; $arr = explode(',',$goods); $goodsUnique = array_filter($arr); if(count($goodsUnique) > 4){ util::failInfo('最多只能推荐5个'); } $goodsUnique[] = $id; $unique = array_unique($goodsUnique); xhRecommendService::updateByMerchantId($this->merchantId, ['goods' =>implode(',',$unique)]); util::successInfo('推荐成功'); } public function actionDelIndexGoods() { $get = Yii::$app->request->get(); $id = isset($get['id']) ? $get['id'] : 0; $goods = xhGoodsService::getById($id); if($goods['merchantId'] != $this->merchantId){ util::failInfo(); } xhRecommendService::wipeGoodsId($id, $this->merchantId); util::successInfo('删除成功'); } }