request->get(); $status = isset($get['status']) ? $get['status'] : -1; $goodsName = isset($get['goodsName']) && !empty($get['goodsName']) ? $get['goodsName'] : ''; $where = []; if ($status != -1) { $where['status'] = $status; } if (!empty($goodsName)) { $where['goodsName'] = ['like', $goodsName]; } if (isset($get['cId']) && $get['cId'] != -1) { $where['cId'] = $get['cId']; } $where['merchantId'] = $this->merchantId; $where['delStatus'] = 0; $data = GoodsService::getGoodsList($where); $asset = MerchantAssetService::getByMerchantId($this->merchantId); $data['MerchantAsset'] = $asset; util::success($data); } //添加商品 shish 2019.12.7 public function actionAdd() { $data = Yii::$app->request->post(); $data['merchantId'] = $this->merchantId; $return = GoodsService::addGoods($data); $id = $return['id']; $info = GoodsService::getById($id); util::success($info); } //获取商品详情 shish 2019.12.7 public function actionDetail() { $id = Yii::$app->request->get('id'); $goods = GoodsService::getGoodsInfo($id); util::success($goods); } //更新商品 shish 2019.12.7 public function actionUpdate() { $data = Yii::$app->request->post(); $id = isset($data['id']) ? $data['id'] : 0; $info = GoodsService::getById($id); GoodsService::valid($info, $this->merchantId); $data['merchantId'] = $this->merchantId; GoodsService::updateGoods($id, $data); util::complete(); } //商品排序 shish 2020.3.11 public function actionSort() { $id = Yii::$app->request->get('id', 0); $cId = Yii::$app->request->get('cId', 0); $inTurn = Yii::$app->request->get('inTurn', 0); //验证商品 $info = GoodsService::getById($id); GoodsService::valid($info, $this->merchantId); if ($cId != 0) { //验证分类 $category = CategoryService::getById($cId); CategoryService::valid($category, $this->merchantId); GoodsCategoryService::updateByCondition(['cId' => $cId, 'gId' => $id], ['inTurn' => $inTurn]); } else { GoodsService::updateById($id, ['inTurn' => $inTurn]); GoodsCategoryService::updateByCondition(['gId' => $id], ['inTurn' => $inTurn]); } util::complete('操作成功'); } //删除商品 shish 2019.12.7 public function actionDelete() { $id = Yii::$app->request->get('id', 0); $goods = GoodsService::getById($id); GoodsService::valid($goods, $this->merchantId); GoodsService::deleteGoods($goods); util::complete(); } //上下架 shish 2019.12.8 public function actionChangeStatus() { $post = Yii::$app->request->post(); $id = isset($post['id']) ? $post['id'] : 0; $status = isset($post['status']) ? $post['status'] : 1; $info = GoodsService::getById($id); GoodsService::valid($info, $this->merchantId); GoodsService::changeStatus($id, $status); util::complete(); } //发送短链接到手机上 shish 2019.12.8 public function actionSendShortUrl() { $id = Yii::$app->request->get('id'); util::complete(); } //查看商品短链接 shish 2019.12.8 public function actionShortUrl() { $id = Yii::$app->request->get('id'); util::success(['shortUrl' => 'https://w.url.cn/s/A8iQl2r']); } //商品说明 shish 2019.12.8 public function actionIntroduce() { $set = GoodsSettingService::getByCondition(['merchantId' => $this->merchantId]); $introduce = $set['goodsIntroduce']; util::success(['introduce' => $introduce]); } //修改商品说明 shish 2019.12.8 public function actionUpdateIntroduce() { $introduce = Yii::$app->request->post('introduce', ''); GoodsSettingService::updateByCondition(['merchantId' => $this->merchantId], ['goodsIntroduce' => $introduce]); util::complete('提交成功'); } //设置 shish 2019.12.8 public function actionSetting() { $return = GoodsSettingService::getSetting($this->merchantId); util::success($return); } //更新涨价 shish 2019.12.9 public function actionUpdateRise() { $post = Yii::$app->request->post(); $festIdList = isset($post['festIdList']) && !empty($post['festIdList']) ? $post['festIdList'] : []; unset($post['festIdList']); $riseSwitch = isset($post['riseSwitch']) && is_numeric($post['riseSwitch']) ? $post['riseSwitch'] : 1; if ($riseSwitch == 1) { if (empty($festIdList)) { util::fail('请选择节日'); } FestRiseService::deleteByCondition(['merchantId' => $this->merchantId]); $add = []; foreach ($festIdList as $festId) { $add[] = ['merchantId' => $this->merchantId, 'festId' => $festId]; } FestRiseService::batchAdd($add); } GoodsSettingService::updateByCondition(['merchantId' => $this->merchantId], $post); util::complete('提交成功'); } }