request->get(); $status = isset($get['status']) && is_numeric($get['status']) ? $get['status'] : -1; $cId = isset($get['cId']) && !empty($get['cId']) ? $get['cId'] : 0; $goodsName = isset($get['goodsName']) && !empty($get['goodsName']) ? $get['goodsName'] : ''; $where = []; if ($status != -1) { $where['status'] = $status; } if (!empty($goodsName)) { $where['goodsName'] = ['like', $goodsName]; } if (!empty($cId)) { $where['cId'] = $cId; } $where['sjId'] = $this->sjId; $where['delStatus'] = 0; $data = GoodsService::getGoodsList($where); $asset = MerchantAssetService::getBySjId($this->sjId); $data['MerchantAsset'] = $asset; util::success($data); } //添加商品 ssh 2019.12.7 public function actionAdd() { $data = Yii::$app->request->post(); $data['sjId'] = $this->sjId; $return = GoodsService::addGoods($data); $id = $return['id']; $info = GoodsService::getById($id); util::success($info); } //获取商品详情 ssh 2019.12.7 public function actionDetail() { $id = Yii::$app->request->get('id'); $goods = GoodsService::getGoodsInfo($id); GoodsClass::valid($goods, $this->sjId); util::success($goods); } //更新商品 ssh 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->sjId); $data['sjId'] = $this->sjId; GoodsService::updateGoods($id, $data); util::complete(); } //商品排序 ssh 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->sjId); if ($cId != 0) { //验证分类 $category = CategoryService::getById($cId); CategoryService::valid($category, $this->sjId); GoodsCategoryService::updateByCondition(['cId' => $cId, 'gId' => $id], ['inTurn' => $inTurn]); } else { GoodsService::updateById($id, ['inTurn' => $inTurn]); GoodsCategoryService::updateByCondition(['gId' => $id], ['inTurn' => $inTurn]); } util::complete('操作成功'); } //删除商品 ssh 2019.12.7 public function actionDelete() { $id = Yii::$app->request->get('id', 0); $goods = GoodsService::getById($id); GoodsService::valid($goods, $this->sjId); GoodsService::deleteGoods($goods); util::complete(); } //上下架 ssh 2019.12.8 public function actionChangeStatus() { $get = Yii::$app->request->get(); $id = isset($get['id']) ? $get['id'] : 0; $status = isset($get['status']) ? $get['status'] : 1; $info = GoodsService::getById($id); GoodsService::valid($info, $this->sjId); GoodsService::changeStatus($id, $status); util::complete(); } //商品说明 ssh 2019.12.8 public function actionIntroduce() { $set = GoodsSettingService::getByCondition(['sjId' => $this->sjId]); $introduce = $set['goodsIntroduce']; util::success(['introduce' => $introduce]); } //修改商品说明 ssh 2019.12.8 public function actionUpdateIntroduce() { $introduce = Yii::$app->request->post('introduce', ''); GoodsSettingService::updateByCondition(['sjId' => $this->sjId], ['goodsIntroduce' => $introduce]); util::complete('提交成功'); } //设置 ssh 2019.12.8 public function actionSetting() { $return = GoodsSettingService::getSetting($this->sjId); util::success($return); } //更新涨价 ssh 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(['sjId' => $this->sjId]); $add = []; foreach ($festIdList as $festId) { $add[] = ['sjId' => $this->sjId, 'festId' => $festId]; } FestRiseService::batchAdd($add); } GoodsSettingService::updateByCondition(['sjId' => $this->sjId], $post); util::complete('提交成功'); } //获取商品详情 ssh 2019.12.3 public function actionMallDetail() { $id = Yii::$app->request->get('id', 0); $info = GoodsService::getGoodsInfo($id); GoodsService::valid($info, $this->sjId); $setting = GoodsSettingService::getByCondition(['sjId' => $this->sjId]); $commonIntro = isset($setting['goodsIntroduce']) ? $setting['goodsIntroduce'] : ''; $info['commonIntro'] = $commonIntro; util::success($info); } public function actionIndex() { $classIds = CategoryService::getCategoryClassAll($this->sjId); $where['sjId'] = $this->sjId; $where['delStatus'] = 0; $goodsData = GoodsCategoryService::getGoodsAll($where); //常用的GoodsId $oftenIds = GoodsCategoryService::getOftenIds($this->sjId); $goodsCateData = GoodsCategoryService::getEnableGoodsCategory($this->sjId); //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}] $data = GoodsCategoryService::assembleData($classIds, $goodsCateData, $goodsData, $oftenIds); util::success($data); } //保存花材组合 shish 2021.4.10 public function actionSaveItemGroup() { $orderSn = Yii::$app->request->post('orderSn', ''); $goodsName = Yii::$app->request->post('name', ''); $classId = Yii::$app->request->post('categoryId', 0); if (empty($goodsName)) { util::fail("名称不能为空"); } $cateExists = CategoryService::exists(['id' => $classId, 'sjId' => $this->sjId]); if (!$cateExists) { util::fail("分类不存在"); } $itemInfo = OrderItemclass::getAllByCondition(['orderSn' => $orderSn], null, "*"); if (empty($itemInfo)) { util::fail("订单不存在"); } $order = OrderService::getOrderBySn($orderSn); OrderService::valid($order, $this->shopId); $save = GoodsService::saveItemGroup($order, $itemInfo, $classId, $goodsName,$this->adminId); if ($save) { util::complete(); } util::fail("保存失败"); } }