| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610 |
- <?php
- namespace addons\Happiness\backend\controllers;
- use addons\Happiness\common\enums\HappinessEnum;
- use addons\Happiness\common\models\HappinessStore;
- use addons\Happiness\common\models\HappinessGoods;
- use addons\Store\common\models\StoreGoodsAttr;
- use addons\Store\common\models\StoreGoodsCate;
- use addons\Store\common\models\StoreGoodsModel;
- use addons\Happiness\common\models\HappinessStoreGoods;
- use addons\Happiness\common\models\HappinessStoreGoodsAttr;
- use addons\Happiness\common\service\GoodsService;
- use common\enums\AddonsEnum;
- use common\enums\GoodsTypeEnum;
- use common\enums\StatusEnum;
- use common\enums\WhetherEnum;
- use common\globals\GlobalInvoke;
- use common\logic\common\AddonsLimit;
- use common\models\goods\Goods;
- use common\models\goods\GoodsMarketing;
- use common\models\mall\MallAddons;
- use common\models\goods\GoodsAssociation;
- use common\helpers\StringHelper;
- use common\models\goods\GoodsCateRelate;
- use Exception;
- use Yii;
- class StoreGoodsController extends BaseController
- {
- public function actionIndex()
- {
- if (!\Yii::$app->request->isAjax) {
- return $this->render('/store-goods/index');
- }
- if (\Yii::$app->request->isGet) {
- //商品列表筛选
- $get = Yii::$app->request->get();
- $rules = [
- [['goods_id','type'], 'integer'],
- [['goods_name', 'sort_field'], 'string'],
- [['sort_type'], 'in', 'range' => ['asc', 'desc']],
- [['cats'], 'each', 'rule' => ['integer']],
- [['start', 'end'], 'datetime', 'format' => 'php:Y-m-d H:i:s']
- ];
- $res = Yii::$app->services->validate->validate($get, $rules);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where[] = ['g.mall_id' => $this->mall_id, 'yg.status' => StatusEnum::ENABLED, 'g.goods_type' => 1];
- if($get['type']>0)
- {
- $where[] = ['yg.label_id' => $get['type']];
- }
- // 筛选
- isset($get['start']) && $where[] = ['>=', 'g.created_at', strtotime($get['start'])];
- isset($get['end']) && $where[] = ['<=', 'g.created_at', strtotime($get['end'])];
- isset($get['goods_name']) && $where[] = ['like', 'g.goods_name', trim($get['goods_name']) . '%', false];
- isset($get['goods_id']) && $where[] = ['=', 'g.id', $get['goods_id']];
- if(!empty($get['cats'])){
- $goods_cate_relate_list = GoodsCateRelate::lists(['where'=>[['cate_id'=>$get['cats']]]]);
- $goods_ids = array_column($goods_cate_relate_list,'goods_id');
- $where[] = ['in', 'g.id', $goods_ids];
- }
- // with
- $with = ['cats'];
- // 排序
- $sort = '';
- if (isset($get['sort_field']) && isset($get['sort_type'])) $sort = 'g.' . $get['sort_field'] . ' ' . $get['sort_type'];
- $sort = !empty($sort) ? $sort . ',g.sort ASC,g.id DESC' : 'g.sort ASC,g.id DESC';
- $params = [
- 'alias' => 'yg',
- 'where' => $where,
- 'with' => $with,
- 'limit' => 20,
- 'order' => $sort,
- 'join' => [['LEFT JOIN', Goods::tableName(). ' as g', "g.id = yg.goods_id"]],
- 'select' => 'yg.id,yg.label_id,yg.store_scale,yg.min_num,yg.freight_type,yg.sales_num,yg.warn_day,g.id as goods_id, g.is_on_sale as goods_sale, g.goods_name, g.price, g.cost_price, g.unit, g.cover_pic, yg.is_on_sale, g.is_attr, g.attr_groups, g.attr_groups, g.status, g.stock, g.virtual_sales, g.goods_type, g.services, g.goods_source, g.check_remark, g.sort, g.created_at, g.stock_warning',
- ];
- $page_data = HappinessGoods::listPage($params);
- //获取标签
- $goods_label= \Yii::$app->services->setting->addons->get($this->mall_id, HappinessEnum::ADDONS_NAME, 'basic.goods_label');
- $goods_label = empty($goods_label) ? [] : json_decode($goods_label,true);
- $page_data['goods_label']=$goods_label;
- $goods_label = array_column($goods_label,null,'level');
- if ($page_data === false) return $this->error(HappinessGoods::getStaticError());
- if (!empty($page_data['list'])) {
- foreach ($page_data['list'] as &$item) {
- $item['label_name']=$goods_label[$item['label_id']]?$goods_label[$item['label_id']]['name']:'';
- $item['freight_type']=isset($item['freight_type'])?json_decode($item['freight_type'],true):[];
- }
- }
- return $this->success('操作成功', $page_data);
- } else {
- // 商品操作
- $form = Yii::$app->request->post();
- $rules = [[['id'], 'required'], [['id'], 'integer']];
- switch ($form['type']) {
- case 'is_on_sale': //上下架
- $rule = [
- [['is_on_sale'], 'required'],
- [['is_on_sale'], 'in', 'range' => [WhetherEnum::ENABLED, WhetherEnum::DISABLED]],
- ];
- $rules = array_merge($rules, $rule);
- break;
- }
- $res = Yii::$app->services->validate->validate($form, $rules);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $form['mall_id'] = $this->mall_id;
- $res = HappinessGoods::setData($form);
- if ($res === false) return $this->error(HappinessGoods::getStaticError());
- return $this->success();
- }
- }
- /**
- * 商品编辑
- * @Author bing
- * @DateTime 2021-08-20 14:49:55
- * @copyright: Copyright (c) 2020 广东七件事集团
- * @return void
- */
- public function actionEdit()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- } else {
- // 编辑商品
- $form = Yii::$app->request->post();
- $form['mall_id'] = $this->mall_id;
- if(isset($form['freight_type']))
- {
- $form['freight_type'] = json_encode($form['freight_type']);
- }
- $res = HappinessGoods::setData($form);
- if ($res === false) return $this->error(HappinessGoods::getStaticError());
- return $this->success('操作成功');
- }
- }
- }
- /**
- * 获取商品模式
- * @Author: lun
- * @DateTime: 2021/10/26 0026 11:47
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return mixed|string|void
- */
- public function actionGoodsModel()
- {
- // 获取组件配置
- $addons_setting = AddonsLimit::getGlobalSetting($this->mall_id);
- $addons_arr = [AddonsEnum::ADDONS_NAME_DISTRIBUTION, AddonsEnum::ADDONS_NAME_AGENT, AddonsEnum::ADDONS_NAME_AREA,AddonsEnum::ADDONS_NAME_DOUBLE_COPY,AddonsEnum::ADDONS_NAME_REBATE];
- if (!empty($addons_setting)) {
- foreach ($addons_setting as $key => $val) {
- if (!in_array($key, $addons_arr)) unset($addons_setting[$key]);
- }
- }
- //门店存在的插件
- if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_STORE_BOSS_AGENT)){
- $setting = \Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_STORE_BOSS_AGENT, 'basic');
- if (!empty($setting['is_enable'])){
- $addons_setting[AddonsEnum::ADDONS_NAME_STORE_BOSS_AGENT] = [
- 'components' => 'com-' . StringHelper::toUnderScore(AddonsEnum::ADDONS_NAME_STORE_BOSS_AGENT),
- 'class' => '',
- ];
- $addons_arr[] = AddonsEnum::ADDONS_NAME_STORE_BOSS_AGENT;
- }
- }
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- // 商品列表筛选
- $params = \Yii::$app->request->get();
- $res = \Yii::$app->services->validate->validate($params, [[['id'], 'required'], [['id'], 'integer']]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- // 获取商品详情
- $detail = HappinessGoods::getOne([['id' => $params['id'], 'mall_id' => $this->mall_id]], true, ['attr']);
- $goods_model = StoreGoodsModel::getOne([['goods_id' => $params['id'], 'mall_id' => $this->mall_id]], true);
- $setting = [];
- if (!empty($goods_model['content'])) {
- $content = json_decode($goods_model['content'], true);
- foreach ($content as $key => $item) {
- if (in_array($key, $addons_arr)) {
- $setting[$key] = json_decode($item, true);
- }
- }
- }
- // 获取等级
- $level_params = ['where' => [['=', 'mall_id', $this->mall_id], ['=', 'status', StatusEnum::ENABLED]], 'select' => 'level,name'];
- $level_params['mall_id'] = $this->mall_id;
- $level = GlobalInvoke::exec(GlobalInvoke::GOODS_MODEL_LEVEL, $this->mall_id, $level_params);
- $commission_type_map = GoodsTypeEnum::getCommissionTypeMap($this->mall_id);
- unset($commission_type_map['digital']);
- return $this->success('操作成功', compact('detail', 'level', 'setting', 'commission_type_map'));
- } else {
- $params = Yii::$app->request->post('form');
- $res = Yii::$app->services->validate->validate($params, [
- [['goods_id', 'store_id'], 'required'],
- [['goods_id', 'store_id'], 'integer'],
- [array_keys($addons_setting), 'string']
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- // dd($params);
- try {
- $param = [
- 'mall_id' => $this->mall_id,
- 'store_id' => $params['store_id'],
- 'goods_id' => $params['goods_id'],
- 'content' => json_encode($params),
- ];
- $res = StoreGoodsModel::setData($param);
- if ($res === false) return $this->error(StoreGoodsModel::getStaticError());
- return $this->success("保存成功");
- } catch (\Exception $e) {
- return $this->error("保存失败,msg=" . $e->getMessage());
- }
- }
- }
- return $this->render('/store-goods/edit', ['addons_settings' => $addons_setting]);
- }
- /**
- * @name:
- * @msg: 商品审核操作
- * @param {*}
- * @return {*}
- */
- public function actionAudit()
- {
- if (!\Yii::$app->request->isPost) {
- return $this->error('请求方式错误');
- }
- $post = \Yii::$app->request->post();
- $rules = [
- [['goods_id', 'type'], 'required'],
- ['goods_id', 'integer'],
- ['type', 'in', 'range' => ['adopt', 'failed']],
- ['check_remark', 'required', 'when' => function ($model) {
- return $model->type == 'failed';
- }],
- ];
- $res = \Yii::$app->services->validate->validate($post, $rules);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $good = HappinessGoods::findOne(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $post['goods_id']]);
- if (empty($good)) {
- return $this->error('商品不存在');
- }
- if ('adopt' == $post['type']) {
- $check_status = 1;
- } else {
- $check_status = 2;
- }
- $good->check_status = $check_status;
- $good->check_remark = $post['check_remark'];
- $good->updated_at = time();
- if (!$good->save()) {
- return $this->error('操作失败');
- }
- return $this->success('操作成功');
- }
- /**
- * @name:
- * @msg: 获取商品分类树形目录
- * @param {*}
- * @return {*}
- */
- public function actionTree()
- {
- if (Yii::$app->request->isAjax) {
- if (Yii::$app->request->isGet) {
- $is_add = Yii::$app->request->get('is_add', 0);
- $store_id = Yii::$app->request->get('store_id', '');
- $cond = [['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED]];
- if (!empty($store_id)) {
- $cond[] = ['store_id' => $store_id];
- }
- if($is_add) $cond[] = ['>', 'store_id', 0];
- $list = StoreGoodsCate::getCates($cond, [], true, 'id,name,parent_id');
- $list = StoreGoodsCate::getTreeCate($list);
- return $this->success('操作成功', compact('list'));
- }
- }
- }
- public function actionMutipleOff()
- {
- // if (!\Yii::$app->request->isPost) {
- // return $this->error('请求方式错误');
- // }
- // $good_ids = \Yii::$app->request->post('good_ids');
- // if (empty($good_ids) || !is_array($good_ids)) {
- // return $this->error('参数错误');
- // }
- //
- // if (empty($good_ids)) {
- // return $this->success('操作成功');
- // }
- //
- // $res = StoreGoods::updateAll(['is_on_sale' => 0, 'updated_at' => time(), 'check_status' => HappinessEnum::CHECK_WAITING], ['mall_id' => $this->mall_id, 'id' => $good_ids]);
- // if (!$res) {
- // return $this->error('操作失败:' . StoreGoods::getStaticError());
- // }
- // return $this->success('操作成功');
- if (!\Yii::$app->request->isPost) {
- return $this->error('请求方式错误');
- }
- $good_ids = \Yii::$app->request->post('good_ids');
- $type = \Yii::$app->request->post('type');
- $where = [];
- $info = HappinessGoods::getOne([
- ['mall_id' => $this->mall_id],
- ['id' => $good_ids],
- ], true);
- if ($type == 1) {
- $where = ['is_on_sale' => 0, 'updated_at' => time()];
- } else if ($type == 2) {
- $where = ['is_on_sale' => 1, 'updated_at' => time()];
- }
- if (!empty($info) && $info['is_on_sale'] == $where['is_on_sale']) return $this->error('该商品已是当前状态');
- if (empty($good_ids) || !is_array($good_ids) || !$type) {
- return $this->error('参数错误');
- }
- if (empty($good_ids)) {
- return $this->success('操作成功');
- }
- $res = HappinessGoods::updateAll($where, ['mall_id' => $this->mall_id, 'id' => $good_ids]);
- if (!$res) {
- return $this->error('操作失败:' . HappinessGoods::getStaticError());
- }
- $res = HappinessStoreGoods::updateAll($where, ['mall_id' => $this->mall_id, 'goods_id' => $info['goods_id']]);
- $res = HappinessStoreGoodsAttr::updateAll($where, ['mall_id' => $this->mall_id, 'goods_id' => $info['goods_id']]);
- return $this->success('操作成功');
- }
- public function actionSearch()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- //商品列表筛选
- $get = Yii::$app->request->get();
- $rules = [
- [['keyword'], 'string']
- ];
- $res = Yii::$app->services->validate->validate($get, $rules);
- if ($res === false)
- return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [['mall_id' => $this->mall['id'], 'is_on_sale' => 1,'check_status'=>1, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]];
- isset($get['keyword']) && $where[] = ['or', ['like', 'goods_name', $get['keyword']], ['=', 'id', $get['keyword']]];
- $sort = !empty($sort) ? $sort . ',sort ASC,id DESC' : 'sort ASC,id DESC';
- $params = array('where' => $where, 'limit' => 15, 'order' => $sort, 'group' => 'id');
- $page_data = HappinessGoods::listPage($params, false, true);
- if ($page_data === false)
- return $this->error(Goods::getStaticError());
- return $this->success('操作成功', $page_data);
- }
- }
- return $this->render($this->action->id);
- }
- public function actionSearchWithStore()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- //商品列表筛选
- $get = Yii::$app->request->get();
- $rules = [
- [['keyword'], 'string']
- ];
- $res = Yii::$app->services->validate->validate($get, $rules);
- if ($res === false)
- return $this->error(Yii::$app->services->validate->getErrorMessage());
- $where = [['mall_id' => $this->mall['id'], 'is_on_sale' => 1,'check_status'=>1, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]];
- isset($get['keyword']) && $where[] = ['or', ['like', 'goods_name', $get['keyword']], ['=', 'id', $get['keyword']]];
- $sort = !empty($sort) ? $sort . ',sort ASC,id DESC' : 'sort ASC,id DESC';
- $params = array('where' => $where, 'limit' => 15, 'order' => $sort, 'group' => 'id');
- $page_data = HappinessGoods::listPage($params, false, true);
- if ($page_data === false)
- return $this->error(Goods::getStaticError());
- if(!empty($page_data['list'])){
- $store_ids = array_column($page_data['list'],'store_id');
- $store_list = HappinessStore::find()->where(['id'=>$store_ids])->indexBy('id')->asArray()->all();
- foreach($page_data['list'] as &$item){
- $item['store_name'] = '';
- if(!empty($store_list[$item['store_id']])){
- $item['store_name'] = $store_list[$item['store_id']]['store_name'];
- }
- }
- }
- return $this->success('操作成功', $page_data);
- }
- }
- return $this->render($this->action->id);
- }
- //获取门店商品
- public function actionGetStoreGoods()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isGet) {
- try {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['store_id', 'goods_id', 'goods_type'], 'integer'],
- [['goods_name', 'start', 'end', 'type'], 'string']
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $list = (new GoodsService(['mall_id' => $this->mall_id]))->getGoodsList($get);
- return $this->success('获取成功', $list);
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //门店商品批量下架
- public function actionStoreGoodsMutiple()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isPost) {
- try {
- $post = $request->post();
- $res = Yii::$app->services->validate->validate($post, [
- [['type', 'store_id'], 'integer'],
- [['good_ids'], 'safe']
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $res = (new GoodsService(['mall_id' => $this->mall_id]))->storeGoodsMutiple($post);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- //查询幸福小店商品
- public function actionSearchGoodsData()
- {
- $request = Yii::$app->request;
- try {
- if ($request->isAjax && $request->isGet) {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [
- [['keyword', 'store_id'], 'string'],
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $info = (new GoodsService(['mall_id' => $this->mall_id, 'store_id' => $get['store_id']]))->searchGoodsData($get);
- return $this->success('获取成功', $info);
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- //添加门店商品
- public function actionEditGoods()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isPost) {
- try {
- $form = Yii::$app->request->post();
- $res = Yii::$app->services->validate->validate($form, [
- [['goods_id', 'id', 'store_id'], 'integer'],
- [['attr'], 'safe']
- ]);
- if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $res = (new GoodsService(['mall_id' => $this->mall_id, 'store_id' => $form['store_id']]))->addGoods($form);
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- }
- public function actionDelGoods()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isPost) {
- try {
- $form = $request->post();
- $rules = [[['id'], 'required']];
- $res = Yii::$app->services->validate->validate($form, $rules);
- if ($res === false) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $form['mall_id'] = $this->mall_id;
- $form['status'] = -1;
- $res=HappinessGoods::setData($form);
- if (!$res) throw new Exception(HappinessGoods::getStaticError());
- return $this->success('操作成功');
- } catch (\Exception $e) {
- $this->error($e->getMessage());
- }
- }
- }
- public function actionGoodsLabel()
- {
- $request = Yii::$app->request;
- if ($request->isGet) {
- $label = \Yii::$app->services->setting->addons->get($this->mall_id, HappinessEnum::ADDONS_NAME, 'basic.goods_label');
- if(isset($label))
- {
- $label_list=json_decode($label, true);
- $label_list=array_column($label_list, null,'level');
- return $this->success('', $label_list);
- }
- return $this->success('', []);
- }
- }
- public function actionAdd()
- {
- $request = Yii::$app->request;
- if ($request->isAjax && $request->isPost) {
- try {
- $form = Yii::$app->request->post();
- if(!empty($form['goods']))
- {
- foreach ($form['goods'] as $goods)
- {
- if(isset($goods['freight_type']))
- {
- $goods['freight_type'] = json_encode($goods['freight_type']);
- }
- $goods['mall_id'] = $this->mall_id;
- $isHas=HappinessGoods::find()->where(['goods_id'=>$goods['goods_id'],'mall_id'=>$this->mall_id])->one();
- if($isHas)
- {
- $goods['id']=$isHas->id;
- }
- $res = HappinessGoods::setData($goods);
- if ($res === false) throw new Exception(HappinessStoreGoods::getStaticError());
- }
- return $this->success('操作成功');
- }
- return $this->error('请选择商品');
- } catch (\Exception $e) {
- $this->error($e->getMessage());
- }
- }
- return $this->render($this->action->id);
- }
- public function actionGoodsSearch()
- {
- if (Yii::$app->request->isAjax) {
- if (Yii::$app->request->isGet) {
- //商品列表筛选
- $get = Yii::$app->request->get();
- $rules = [
- [['keyword'], 'string'],
- [['is_partake_goods', 'goods_id','screen_main_goods','req','reqId','price','sudoku_is_attr'], 'safe'],
- [['goods_type'],'safe']
- ];
- $res = Yii::$app->services->validate->validate($get, $rules);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $sort = !empty($sort) ? $sort . ',sort ASC,id DESC' : 'sort ASC,id DESC';
- $goods_ids=HappinessGoods::find()->select('goods_id')->where(['mall_id'=>$this->mall_id,'status'=>StatusEnum::ENABLED])
- ->asArray()
- ->column();
- $data = Goods::getPaginationList(15, function($query) use ($get,$goods_ids) {
- $where = [
- 'and',
- [
- 'mall_id' => $this->mall_id,
- 'mch_id' => $this->admin->mch_id,
- 'is_on_sale' => 1,
- 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED],
- ],
- ['not in','id',$goods_ids]
- ];
- isset($get['keyword']) && $where[] = ['or', ['like', 'goods_name', $get['keyword']], ['=', 'id', $get['keyword']]];
- if(!empty($get['price'])){
- $where[]=['price'=>trim($get['price'])];
- }
- if (isset($get['sudoku_is_attr'])) { // 九宫格插件关联商品。只显示单规格
- $where[] = ['is_attr' => 0];
- }
- if (isset($get['goods_id']) && !empty($get['goods_id'])) {
- $where[] = ['!=', 'id', $get['goods_id']];
- }
- if (isset($get['goods_type']) && !empty($get['goods_type'])) {
- if(is_array($get['goods_type'])){
- $where[] = ['in', 'goods_type', $get['goods_type']];
- } elseif (is_string($get['goods_type'])) {
- $where[] = ['goods_type' => explode(',', $get['goods_type'])];
- }else{
- $where[] = ['=', 'goods_type', $get['goods_type']];
- }
- }
- $query->where($where);
- }, $sort);
- return $this->success('操作成功', $data);
- }
- }
- return $this->render($this->action->id);
- }
- }
|