| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- /**
- * Created by PhpStorm.
- * User: admin
- * Date: 2019/12/1
- * Time: 13:55
- */
- namespace ghs\controllers;
- use bizHd\goods\services\CategoryService;
- use bizHd\goods\services\GoodsCategoryService;
- use bizHd\goods\services\GoodsSettingService;
- use biz\sj\services\MerchantAssetService;
- use bizHd\saas\services\FestRiseService;
- use Yii;
- use common\components\util;
- use bizHd\goods\services\GoodsService;
- class GoodsController extends BaseController
- {
- //商品列表 ssh 2019.12.7
- public function actionList()
- {
- }
- //商品排序 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->mainId);
- if ($cId != 0) {
- //验证分类
- $category = CategoryService::getById($cId);
- CategoryService::valid($category, $this->mainId);
- 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->mainId);
- GoodsService::deleteGoods($goods);
- util::complete();
- }
- //上下架 ssh 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->mainId);
- GoodsService::changeStatus($id, $status);
- util::complete();
- }
- //发送短链接到手机上 ssh 2019.12.8
- public function actionSendShortUrl()
- {
- $id = Yii::$app->request->get('id');
- util::complete();
- }
- //查看商品短链接 ssh 2019.12.8
- public function actionShortUrl()
- {
- $id = Yii::$app->request->get('id');
- util::success(['shortUrl' => 'https://w.url.cn/s/A8iQl2r']);
- }
- //商品说明 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('提交成功');
- }
- }
|