render($this->action->id); } /** * 商品列表 * * @return void */ public function actionList() { $scoreExpansionRecommendRewardGoodsService = new ScoreExpansionRecommendRewardGoodsService(['mall_id' => $this->mall_id]); $this->success('success', $scoreExpansionRecommendRewardGoodsService->list($this->request->get())); } /** * 设置独立奖励 * * @return void */ public function actionEdit() { $post = $this->request->post(); $res = Yii::$app->services->validate->validate($post, [ [['id', 'is_alone', 'setting'], 'required'], [['id', 'is_alone'], 'integer'], ]); if ($res === false) { $this->error(Yii::$app->services->validate->getErrorMessage()); return; } $scoreExpansionRecommendRewardGoodsService = new ScoreExpansionRecommendRewardGoodsService(['mall_id' => $this->mall_id]); if (!$scoreExpansionRecommendRewardGoodsService->edit($post)) { $this->error($scoreExpansionRecommendRewardGoodsService->getError()); return; } $this->success(); } /** * 删除商品 * * @return void */ public function actionDel() { $scoreExpansionRecommendRewardGoodsService = new ScoreExpansionRecommendRewardGoodsService(['mall_id' => $this->mall_id]); if (!$scoreExpansionRecommendRewardGoodsService->del($this->request->post('id'))) { $this->error($scoreExpansionRecommendRewardGoodsService->getError()); return; } $this->success(); } /** * 添加商品 * * @return void * @throws Exception */ public function actionSave() { $post = $this->request->post(); $res = Yii::$app->services->validate->validate($post, [ [['goods_ids'], 'required'], ]); if ($res === false) { $this->error(Yii::$app->services->validate->getErrorMessage()); return; } $scoreExpansionRecommendRewardGoodsService = new ScoreExpansionRecommendRewardGoodsService(['mall_id' => $this->mall_id]); if (!$scoreExpansionRecommendRewardGoodsService->save($post['goods_ids'])) { $this->error($scoreExpansionRecommendRewardGoodsService->getError() ?: '添加失败'); return; } $this->success(); } }