| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- <?php
- namespace addons\Mch\client\controllers;
- use addons\Mch\common\enums\MchEnum;
- use addons\Mch\common\models\MchGoodsModel;
- use addons\Mch\common\models\MchSettings;
- 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\FreightRules;
- use common\models\goods\Goods;
- use common\models\goods\GoodsAttr;
- use common\models\goods\GoodsLabel;
- use common\models\goods\GoodsMarketing;
- use common\models\goods\GoodsService;
- use common\models\user\UserLevel;
- use Exception;
- use Yii;
- use function GuzzleHttp\Psr7\str;
- class GoodsController extends BaseController
- {
- public $enableCsrfValidation = false;
- /**
- * Renders the index view for the module
- * @return string
- */
- public function actionIndex()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- //商品列表筛选
- $get = Yii::$app->request->get();
- $rules = [
- [['goods_id'], 'integer'],
- [['goods_name', 'sort_field'], 'string'],
- [['type'], 'in', 'range' => ['all', 'checking', 'onsale', 'offline', 'sell-out', 'stock-lack']],
- [['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, 'g.mch_id' => $this->mch_id, 'g.status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]];
- // 筛选
- 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['cats']) && $where[] = ['in', 'gcr.cate_id', $get['cats']];
- isset($get['goods_id']) && $where[] = ['=', 'g.id', $get['goods_id']];
- if (isset($get['type'])) {
- switch ($get['type']) {
- case 'checking':
- $where[] = ['=', 'g.check_status', 0];
- break;
- case 'onsale':
- $where[] = ['=', 'g.is_on_sale', WhetherEnum::ENABLED];
- $where[] = ['=', 'g.check_status', 1];
- $where[] = ['>', 'g.stock', 0];
- break;
- case 'offline':
- $where[] = ['=', 'g.is_on_sale', WhetherEnum::DISABLED];
- break;
- case 'sell-out':
- $where[] = ['=', 'g.stock', 0];
- break;
- case 'stock-lack':
- $where[] = new \yii\db\Expression('`stock` <= `stock_warning`');
- break;
- }
- }
- //连表
- $joins = array(['LEFT JOIN', '{{%goods_cate_relate}} gcr', 'gcr.goods_id=g.id']);
- // with
- $with = ['cats', 'attr'];
- // 排序
- $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 = array('alias' => 'g', 'where' => $where, 'join' => $joins, 'with' => $with, 'limit' => 20, 'order' => $sort, 'group' => 'g.id');
- $page_data = Goods::listPage($params, false, true);
- if ($page_data === false) return $this->error(Goods::getStaticError());
- $page_data["export_list"] = Goods::fieldsList();
- $goods_marketing_arr = [];
- if (!empty($page_data['list'])) {
- $goods_id_arr = array_column($page_data['list'], 'id');
- $goods_marketing_list = GoodsMarketing::lists(['where' => [['mall_id' => $this->mall_id], ['goods_id' => $goods_id_arr], ['status' => StatusEnum::ENABLED]], 'select' => 'goods_id,marketing_type']);
- foreach ($goods_marketing_list as $val) {
- $goods_marketing_arr[$val['goods_id']][] = $val['marketing_type'];
- }
- foreach ($page_data['list'] as &$item) {
- $addons_name = '';
- if (isset($goods_marketing_arr[$item['id']])) {
- foreach ($goods_marketing_arr[$item['id']] as $value) {
- if (is_string(AddonsEnum::getAddonsNameMap($value))) $addons_name .= AddonsEnum::getAddonsNameMap($value) . ',';
- }
- $addons_name = trim($addons_name, ',');
- }
- $item['addons_name'] = $addons_name;
- }
- }
- return $this->success('操作成功', $page_data);
- } else {
- // 商品操作
- $form = Yii::$app->request->post();
- $rules = [[['id'], 'required'], [['id'], 'integer']];
- switch ($form['type']) {
- case 'sort': //排序
- $rules[] = [['sort'], 'required'];
- break;
- case 'destroy': //删除
- $form['status'] = -1;
- $rules[] = [['status'], 'required'];
- break;
- case 'goods_name': //修改商品名称
- $rules[] = [['goods_name'], 'required'];
- break;
- case 'is_on_sale': //上下架
- $goods_model = Goods::findOne(['id' => $form['id'], 'mall_id' => $this->mall_id, 'status' => [StatusEnum::ENABLED]]);
- if ($goods_model['check_status'] != 1) {
- if ($form['is_on_sale'] == 1) {
- return $this->error('未通过审核的商品,不能上架');
- }
- }
- $rules[] = [['is_on_sale'], 'required'];
- $rules[] = [['is_on_sale'], 'in', 'range' => [WhetherEnum::ENABLED, WhetherEnum::DISABLED]];
- 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;
- $goods_id = $form['id'];
- unset($form['id']);
- $res = Goods::goodsHandle($goods_id, $form);
- if ($res === false) return $this->error(Goods::getStaticError());
- //修改商品的规格
- if ($form['status']) {
- $attr_goods = GoodsAttr::find()->where(['goods_id' => $goods_id])->all();
- foreach ($attr_goods as $model) {
- $model->status = $form['status'];
- $model->updated_at = time();
- $model->update(false);
- }
- }
- return $this->success();
- }
- }
- return $this->render($this->action->id);
- }
- /**
- * 商品编辑
- * @Author bing
- * @DateTime 2021-08-20 14:49:55
- * @return void
- * @copyright: Copyright (c) 2020 广东七件事集团
- */
- public function actionEdit()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- // 反显商品信息
- $get = \Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($get, [[['id'], 'integer']]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- $detail = isset($get['id']) ? Goods::getOne([[
- 'id' => $get['id'], 'mall_id' => $this->mall_id,
- 'mch_id' => $this->mch_id
- ]], true, ['cats', 'attr', 'extra']) : [];
- $detail['freight_type'] = !empty($detail['freight_type']) ? explode(',', $detail['freight_type']) : [1];
- $detail['services'] = !empty($detail['services']) ? explode(',', $detail['services']) : [];
- $detail['labels'] = !empty($detail['labels']) ? explode(',', $detail['labels']) : [];
- $detail['attr_groups'] = json_decode($detail['attr_groups'], true) ?? [];
- $detail['bannar_pic'] = json_decode($detail['bannar_pic'], true) ?? [];
- $detail['attr_groups_format'] = json_decode($detail['attr_groups_format'], true) ?? [];
- $detail['area_limit'] = json_decode($detail['area_limit'], true) ?? [];
- $detail['cats'] = $detail['cats'] ?? [];
- $detail['attr'] = GoodsAttr::formatFormAttr($detail['attr'] ?? [], $detail['attr_groups_format']);
- $detail['goods_weight'] = isset($detail['attr'][0]['weight']) ? $detail['attr'][0]['weight'] : 0;
- if (isset($detail['extra'])) {
- $extra = &$detail['extra'];
- $extra['score_give_setting'] = json_decode($extra['score_give_setting'], true) ?? [];
- $extra['score_deduct_setting'] = json_decode($extra['score_deduct_setting'], true) ?? [];
- $extra['currency_deduct_setting'] = json_decode($extra['currency_deduct_setting'], true) ?? [];
- $extra['member_price_setting'] = json_decode($extra['member_price_setting'], true) ?? [];
- $extra['member_buy_limit_setting'] = json_decode($extra['member_buy_limit_setting'], true) ?? [];
- }
- unset($detail['attr_groups_format']);
- // 新建商品设置默认属性
- if (empty($get['id'])) $detail = Goods::getDefaultSetting($this->mall_id, $detail, $this->mch_id);
- // 用户等级
- $levels = UserLevel::getUserLevel([['mall_id' => $this->mall_id], ['status' => StatusEnum::ENABLED]], [], true, 'id,level,name');
- $levels = array_merge([['level' => 0, 'name' => '普通用户']], $levels);
- // 运费模板
- $cond = [['mall_id' => $this->mall_id, 'mch_id' => $this->mch_id]];
- $freight_rules = FreightRules::getFreightRules($cond, [], true, 'id,name');
- // 商品类型
- $goods_type = GoodsTypeEnum::getGoodsType();
- if (!empty($goods_type[3])) unset($goods_type[3]);
- $detail['mch_id'] = $detail['mch_id'] ?? $this->mch_id;
- // $cates = GoodsCate::getCates($cond,[],true,'id,name,parent_id');
- // $cates = GoodsCate::getTreeCate($cates);
- // 获取商品标签
- $labels = GoodsLabel::getLabels($cond, [], true, 'id,title,sub_title');
- $services = GoodsService::getServices($cond, [], true, 'id,name');
- return $this->success('操作成功', compact('detail', 'levels', 'goods_type', 'freight_rules', 'labels', 'services'));
- } else {
- // 编辑商品
- $form = json_decode(Yii::$app->request->post('form'), true);
- if (empty($form['check_status'])) {
- $form['check_status'] = 0;
- $form['is_on_sale'] = 0;
- } else {
- if ($form['check_status'] == 2) {
- $form['check_status'] = 0;
- }
- }
- $basic = \Yii::$app->services->setting->addons->get($this->mall_id, MchEnum::ADDONS_NAME, 'basic');
- if (empty($basic['goods_auth'])) {
- $form['check_status'] = 1;
- } else {
- $form['check_status'] = 0; // 开启了审核,保存都要重新审核
- }
- $form['mall_id'] = $this->mall_id;
- $form['mch_id'] = $this->mch_id;
- $form['supplier_type'] = MchEnum::SUPPLIER_SELF;
- $form['supplier_id'] = $this->mch_id;
- $form['supplier_id'] = $this->mch_id;
- $form['supplier_goods_id'] = 0;
- $form['shipping_fee'] = !empty($form['shipping_fee']) ? $form['shipping_fee'] : 0;
- $form['free_shipping_num'] = !empty($form['free_shipping_num']) ? $form['free_shipping_num'] : 0;
- $form['free_shipping_money'] = !empty($form['free_shipping_money']) ? $form['free_shipping_money'] : 0;
- $res = Goods::setData($form);
- if ($res === false) return $this->error(Goods::getStaticError());
- return $this->success('操作成功');
- }
- }
- // 公共调用
- $install_addons = GlobalInvoke::exec(GlobalInvoke::GOODS_DETAIL_EDIT, $this->mall_id, [
- 'type' => 'show_mch_component',
- 'mall_id' => $this->mall_id,
- ]);
- foreach ($install_addons as $key => $val) {
- if (!is_array($val)) {
- unset($install_addons[$key]);
- }
- $component = $val['component'] ?? '';
- if ($component != 'com-higo') {
- unset($install_addons[$key]);
- }
- }
- return $this->render($this->action->id, ['components' => $install_addons, 'install_enable_addons' => $install_enable_addons]);
- }
- /**
- * 选品中心
- * @Author bing
- * @DateTime 2022-04-26 18:05:56
- * @return void
- * @copyright: Copyright (c) 2022 广东七件事集团
- */
- public function actionSupply()
- {
- return $this->render($this->action->id);
- }
- public function actionGoodsModel()
- {
- // 获取组件配置
- $addons_setting = AddonsLimit::getGlobalSetting($this->mall_id);
- $addons_arr = [];
- $basic = \Yii::$app->services->setting->addons->get($this->mall_id, MchEnum::ADDONS_NAME, 'basic');
- $mch_setting = MchSettings::findOne(['mch_id'=>$this->mch_id]);
- $store_commission_authority = [];
- if(!empty($mch_setting)){
- $store_commission_authority = json_decode($mch_setting['store_commission_authority'],true);
- }
- if (!empty($basic['store_agent_status'])){
- if(!isset($store_commission_authority['agent'])||!empty($store_commission_authority['agent'])){
- $addons_arr[] = AddonsEnum::ADDONS_NAME_AGENT;
- }
- }
- if (!empty($basic['store_area_status'])){
- if(!isset($store_commission_authority['area'])||!empty($store_commission_authority['area'])) {
- $addons_arr[] = AddonsEnum::ADDONS_NAME_AREA;
- }
- }
- if (!empty($basic['store_distribution_status'])){
- if(!isset($store_commission_authority['distribution'])||!empty($store_commission_authority['distribution'])) {
- $addons_arr[] = AddonsEnum::ADDONS_NAME_DISTRIBUTION;
- }
- }
- if (!empty($basic['store_boss_status'])){
- if(!isset($store_commission_authority['boss'])||!empty($store_commission_authority['boss'])) {
- $addons_arr[] = AddonsEnum::ADDONS_NAME_BOSS;
- }
- }
- if ($addons_setting) {
- foreach ($addons_setting as $key => $val) {
- if (!in_array($key, $addons_arr)) unset($addons_setting[$key]);
- }
- } else {
- $addons_setting = [];
- }
- 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 = Goods::getOne([['id' => $params['id'], 'mall_id' => $this->mall_id, 'mch_id' => $this->mch_id]], true, ['attr']);
- $goods_model = MchGoodsModel::getOne([['goods_id' => $params['id'], 'mall_id' => $this->mall_id, 'mch_id' => $this->mch_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']);
- // 商品支持的插件分佣币种
- // $addons_commission_type = GlobalInvoke::exec(GlobalInvoke::INVOKE_COMMISSION_TYPE, $this->mall_id, ['mall_id' => $this->mall_id]);
- $addons_commission_type = [];
- foreach ($addons_commission_type as $type) {
- $commission_type_map = array_merge($commission_type_map, array_column($type, 'label', 'name'));
- }
- return $this->success('操作成功', compact('detail', 'level', 'setting', 'commission_type_map'));
- } else {
- $basic = \Yii::$app->services->setting->addons->get($this->mall_id, MchEnum::ADDONS_NAME, 'basic');
- $mch_setting = MchSettings::findOne(['mch_id'=>$this->mch_id,'mall_id'=>$this->mall_id]);
- if(!empty($mch_setting)){
- if($mch_setting['store_settle_type']!=4){
- return $this->error('分佣由平台承担,您无权编辑');
- }
- }else{
- if($basic['settle_type']!=4){
- return $this->error('分佣由平台承担,您无权编辑');
- }
- }
- $params = Yii::$app->request->post('form');
- $res = Yii::$app->services->validate->validate($params, [
- [['goods_id'], 'required'],
- [['goods_id'], 'integer'],
- [array_keys($addons_setting), 'string']
- ]);
- if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
- try {
- $param = [
- 'mall_id' => $this->mall_id,
- 'mch_id' => $this->mch_id,
- 'goods_id' => $params['goods_id'],
- 'content' => json_encode($params),
- ];
- $res = MchGoodsModel::setData($param);
- if ($res === false) return $this->error(MchGoodsModel::getStaticError());
- return $this->success("保存成功");
- } catch (\Exception $e) {
- return $this->error("保存失败,msg=" . $e->getMessage());
- }
- }
- }
- return $this->render($this->action->id, ['addons_setting' => $addons_setting]);
- }
- public function actionBatchChangeStatus()
- {
- try {
- $params = Yii::$app->request->post();
- Goods::updateAll(
- [
- 'is_on_sale' => $params['status'],
- 'updated_at' => time()],
- [
- 'id' => $params['ids'],
- 'mall_id' => $this->mall_id,
- 'mch_id' => $this->mch_id
- ]
- );
- return $this->success('操作成功');
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- //商品服务
- public function actionGoodsService()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- try {
- if ($request->isGet) {
- $keyword = Yii::$app->request->get('keyword', '');
- $where = [['mall_id' => $this->mall['id'], 'mch_id' => $this->mch_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]];
- $limit = Yii::$app->request->get('limit', $this->pageSize);
- $keyword && $where[] = ['like', 'name', $keyword . '%', false];
- $order = 'sort asc,id desc';
- $params = compact('where', 'order', 'limit');
- $page_data = GoodsService::listPage($params, false);
- return $this->success('操作成功', $page_data);
- }
- if ($request->isPost) {
- $form = Yii::$app->request->post();
- $rules = [[['id'], 'required'], [['id'], 'integer']];
- switch ($form['type']) {
- case 'sort': //排序
- $rules[] = [['sort'], 'required'];
- break;
- case 'destroy': //删除
- $form['status'] = -1;
- $rules[] = [['status'], 'required'];
- break;
- case 'default': //设置默认值
- $rules[] = [['is_default'], 'required'];
- break;
- }
- $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['mch_id'] = $this->mch_id;
- $res = GoodsService::setData($form);
- if ($res === false) throw new Exception(GoodsService::getStaticError());
- return $this->success('操作成功', $form);
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- return $this->render($this->action->id);
- }
- //商品服务编辑
- public function actionServiceEdit()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- try {
- if ($request->isGet) {
- $get = Yii::$app->request->get();
- $res = Yii::$app->services->validate->validate($get, [[['id'], 'required'], [['id'], 'integer']]);
- if ($res === false) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $detail = GoodsService::getOne([['id' => $get['id'], 'mall_id' => $this->mall_id, 'mch_id' => $this->mch_id]], true);
- return $this->success('操作成功', compact('detail'));
- }
- if ($request->isPost) {
- $form = Yii::$app->request->post('form');
- $res = Yii::$app->services->validate->validate($form, [
- [['name'], 'required'],
- [['id'], 'integer'],
- [['is_default', 'sort', 'remark'], 'safe'],
- ]);
- if ($res === false) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $form['mall_id'] = $this->mall['id'];
- $form['mch_id'] = $this->mch_id;
- $res = GoodsService::setData($form);
- if ($res === false) throw new Exception(GoodsService::getStaticError());
- return $this->success('操作成功');
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- return $this->render($this->action->id);
- }
- //商品标签
- public function actionGoodsLabel()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- try {
- if ($request->isGet) {
- $keyword = $request->get('keyword', '');
- $where = [['mall_id' => $this->mall_id, 'mch_id' => $this->mch_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]];
- $keyword && $where[] = ['like', 'title', $keyword . '%', false];
- $order = 'sort asc,created_at desc';
- $params = compact('where', 'order');
- $page_data = GoodsLabel::listPage($params, false);
- return $this->success('操作成功', $page_data);
- } else {
- $form = $request->post();
- $rules = [[['id'], 'required'], [['id'], 'integer']];
- switch ($form['type']) {
- case 'sort':
- $rules[] = [['sort'], 'required'];
- break;
- case 'destroy':
- $form['status'] = -1;
- $rules[] = [['status'], 'required'];
- break;
- case 'default':
- $rules[] = [['is_default'], 'integer'];
- break;
- }
- $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'];
- $res = GoodsLabel::setData($form);
- if ($res === false) throw new Exception(GoodsLabel::getStaticError());
- return $this->success('操作成功', $form);
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- return $this->render($this->action->id);
- }
- //添加、编辑商品标签
- public function actionLabelEdit()
- {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- try {
- if ($request->isGet) {
- $get = $request->get();
- $res = Yii::$app->services->validate->validate($get, [[['id'], 'required'], [['id'], 'integer']]);
- if ($res === false) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $detail = GoodsLabel::getOne([['id' => $get['id'], 'mch_id' => $this->mch_id, 'mall_id' => $this->mall_id]], true);
- return $this->success('操作成功', compact('detail'));
- } else {
- $form = $request->post('form');
- $res = Yii::$app->services->validate->validate($form, [
- [['title'], 'required'],
- [['id'], 'integer'],
- [['sort', 'sub_title'], 'safe'],
- ]);
- if ($res === false) throw new Exception(Yii::$app->services->validate->getErrorMessage());
- $form['mall_id'] = $this->mall_id;
- $form['mch_id'] = $this->mch_id;
- $res = GoodsLabel::setData($form);
- if ($res === false) throw new Exception(GoodsLabel::getStaticError());
- return $this->success('操作成功');
- }
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
- return $this->render($this->action->id);
- }
- }
|