| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 |
- <?php
- namespace addons\Mch\backend\controllers;
- use addons\Agent\common\models\AgentLevel;
- use addons\Distribution\common\models\DistributionLevel;
- use addons\Mch\common\enums\MchEnum;
- use addons\Mch\common\models\Mch;
- use addons\Mch\common\models\MchAdmin;
- use addons\Mch\common\models\MchCate;
- use addons\Mch\common\models\MchSettings;
- use common\enums\AddonsEnum;
- use common\enums\ApiStatusEnum;
- use common\enums\StatusEnum;
- use common\helpers\RegularHelper;
- use common\models\common\Region;
- use common\models\goods\Goods;
- use common\models\mall\MallAddons;
- use common\models\mall\MallHost;
- use common\models\user\User;
- use common\models\user\UserLevel;
- class StoreController extends BaseController
- {
- public function actionIndex()
- {
- if (!\Yii::$app->request->isAjax) {
- return $this->render('/store/index');
- }
- if (\Yii::$app->request->isGet) {
- $page = \Yii::$app->request->get('page', 1);
- $limit = \Yii::$app->request->get('limit', $this->pageSize);
- $store_name = \Yii::$app->request->get('store_name');
- $cate_id = \Yii::$app->request->get('cate_id');
- $storeowner = \Yii::$app->request->get('storeowner');
- $nickname = \Yii::$app->request->get('nickname');
- // 门店状态,1:正常;2:过期;3:禁用
- $status = \Yii::$app->request->get('status');
- $time = time();
- $wheres[] = ['mall_id' => $this->mall_id, 'check_status' => MchEnum::CHECK_ADOPT];
- if (empty($status)) {
- $wheres[] = ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]];
- } else {
- if (1 == $status) {
- $wheres[] = ['status' => StatusEnum::ENABLED];
- $wheres[] = ['or', ['>=', 'expire_time', $time], ['expire_time' => 0]];
- } elseif (2 == $status) {
- $wheres[] = ['status' => StatusEnum::ENABLED];
- $wheres[] = ['<=', 'expire_time', $time];
- } elseif (3 == $status) {
- $wheres[] = ['status' => StatusEnum::DISABLED];
- } else {
- return $this->error('参数错误');
- }
- }
- if (!empty($cate_id)) {
- $wheres[] = ['c_id' => $cate_id];
- }
- if (!empty($store_name)) {
- $wheres[] = ['like', 'store_name', $store_name];
- }
- if (!empty($storeowner)) {
- $wheres[] = ['like', 'shop_owner', $storeowner];
- }
- if (!empty($nickname)) {
- $users = User::find()
- ->select('id,nickname,mobile,avatar_url')
- ->where(['like', 'nickname', $nickname])
- ->andWhere(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->indexBy('id')
- ->all();
- $user_ids = array_column($users, 'id');
- $wheres[] = ['user_id' => $user_ids];
- }
- $params = [
- 'select' => 'id,mall_id,user_id,shop_owner,shop_mobile,store_name,c_id,province_id,city_id,district_id,check_status,address,logo_img,total_money,balance,expire_time,user_nums,status,created_at',
- 'where' => $wheres,
- 'order' => 'created_at desc',
- 'page' => $page,
- 'limit' => $limit,
- ];
- $store_list = Mch::listPage($params);
- if (false === $store_list) {
- return $this->error(Mch::getStaticError());
- }
- if (!empty($store_list['list'])) {
- if (empty($users)) {
- $user_ids = array_unique(array_column($store_list['list'], 'user_id'));
- $users = User::find()
- ->select('id,nickname,mobile,avatar_url')
- ->where(['id' => $user_ids, 'mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->indexBy('id')
- ->all();
- }
- $H5Url = MallHost::getHost($this->mall_id,'h5_url');
- foreach ($store_list['list'] as &$list) {
- $user = $users[$list['user_id']] ?? [];
- $list['nickname'] = $user['nickname'] ?? '';
- $list['avatar_url'] = $user['avatar_url'] ?: \Yii::$app->request->hostInfo . '/resources/img/common/default-avatar.png';
- // 门店状态,1:正常;2:过期;3:禁用
- if ($list['status'] == StatusEnum::ENABLED && $list['check_status'] == MchEnum::CHECK_ADOPT && ($list['expire_time'] > $time || $list['expire_time'] == 0)) {
- $list['store_status'] = 1;
- } elseif ($list['status'] == StatusEnum::ENABLED && $list['check_status'] == MchEnum::CHECK_ADOPT && $list['expire_time'] <= $time) {
- $list['store_status'] = 2;
- } elseif ($list['status'] == StatusEnum::DISABLED) {
- $list['store_status'] = 3;
- } else {
- $list['store_status'] = 1;
- }
- $list['promotion_code'] = $H5Url . '/#/plugins/Mch/store/index?mch_id='.$list['id'] . '&sign=' . $this->mall['mall_sign'];
- }
- }
- $store_list['store_login_url'] = \Yii::$app->request->hostInfo . '?r=mch/client/auth/login&sign=' . $this->mall['mall_sign'];
- return $this->success('success', $store_list);
- }
- }
- /**
- * @name:
- * @msg: 切换门店状态
- * @param {*}
- * @return {*}
- */
- public function actionSwitchStatus()
- {
- if (!\Yii::$app->request->isPost) {
- return $this->error('请求方式错误');
- }
- $post = \Yii::$app->request->post();
- $rules = [
- [['mch_id', 'status'], 'required'],
- [['mch_id', 'status'], 'integer'],
- ['status', 'in', 'range' => [1, 3]],
- ];
- $res = \Yii::$app->services->validate->validate($post, $rules);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- if (1 == $post['status']) {
- $status = StatusEnum::ENABLED;
- } else {
- $status = StatusEnum::DISABLED;
- }
- $params = [
- 'id' => $post['mch_id'],
- 'status' => $status,
- 'mall_id' => $this->mall_id,
- ];
- $res = Mch::setData($params);
- if (false === $res) {
- return $this->error(Mch::getStaticError());
- }
- return $this->success('操作成功');
- }
- /**
- * @name:
- * @msg: 根据地区id获取第一层子级地区信息列表
- * @param {*}
- * @return {*}
- */
- public function actionGetRegions()
- {
- if (!\Yii::$app->request->isGet) {
- return $this->error('请求方式错误');
- }
- $region_id = \Yii::$app->request->get('region_id');
- if (empty($region_id)) {
- return $this->error('参数错误');
- }
- $region = Region::findOne($region_id);
- if (empty($region)) {
- return $this->error('地区信息未找到');
- }
- $region_list = Region::find()
- ->select('id,name,lng,lat')
- ->where(['parent_id' => $region->id])
- ->asArray()
- ->all();
- return $this->success('success', $region_list);
- }
- /**
- * @name:
- * @msg: 获取会员列表
- * @param {*}
- * @return {*}
- */
- public function actionGetUsers()
- {
- if (!\Yii::$app->request->isGet) {
- return $this->error('请求方式错误');
- }
- $user_id = \Yii::$app->request->get('user_id');
- $keyword = \Yii::$app->request->get('keyword');
- $page = \Yii::$app->request->get('page', 1);
- $limit = \Yii::$app->request->get('limit', $this->pageSize);
- $wheres[] = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED];
- if (!empty($user_id)) {
- $wheres[] = ['id' => $user_id];
- }
- if (!empty($keyword)) {
- $wheres[] = ['or', ['like', 'nickname', $keyword], ['like', 'mobile', $keyword]];
- }
- $params = [
- 'select' => 'id,nickname,avatar_url,mobile,level,parent_id',
- 'where' => $wheres,
- 'order' => 'created_at desc',
- 'page' => $page,
- 'limit' => $limit,
- ];
- $user_list = User::listPage($params);
- if (empty($user_list['list'])) {
- if (false === $user_list['list']) {
- return $this->error(User::getStaticError());
- }
- } else {
- $levels = UserLevel::find()
- ->select('id,level,name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->indexBy('level')
- ->all();
- $parent_ids = array_column($user_list['list'], 'parent_id');
- $parent_users = User::find()
- ->select('id,nickname,avatar_url,mobile,level,parent_id')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $parent_ids])
- ->asArray()
- ->indexBy('id')
- ->all();
- foreach ($user_list['list'] as &$user) {
- if (empty($user['avatar_url'])) {
- $user['avatar_url'] = \Yii::$app->request->hostInfo . '/resources/img/common/default-avatar.png';
- }
- $level = $levels[$user['level']] ?? [];
- $parent_user = $parent_users[$user['parent_id']] ?? [];
- $user['level_name'] = $level['name'] ?? '';
- $user['parent_nickname'] = $parent_user['nickname'] ?? '';
- }
- }
- return $this->success('success', $user_list);
- }
- /**
- * @name:
- * @msg: 门店添加/编辑
- * @param {*}
- * @return {*}
- */
- public function actionStorage()
- {
- if (!\Yii::$app->request->isAjax) {
- return $this->render('/store/add-edit');
- }
- if (\Yii::$app->request->isGet) {
- $cate_list = MchCate::find()
- ->select('id,name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- return $this->success('success', ['list' => $cate_list]);
- } else {
- $post = \Yii::$app->request->post();
- // dd($post);
- $rules = [
- [['user_id', 'shop_mobile', 'shop_owner', 'store_name', 'c_id','logo_img', 'license_img'], 'required'],
- [['user_id', 'shop_mobile'], 'integer'],
- [['shop_owner', 'store_name', 'store_desc', 'logo_img', 'license_img'], 'string', 'max' => 255],
- [['logo_img', 'license_img'], 'url'],
- ['shop_mobile', function ($attribute, $params) {
- if (!RegularHelper::verify('mobile', $this->$attribute)) {
- $this->addError($attribute, '手机号格式错误');
- }
- }],
- ['store_desc', 'safe']
- ];
- $res = \Yii::$app->services->validate->validate($post, $rules);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- if(empty($post['store_desc']))$post['store_desc'] = '';
- $post['mall_id'] = $this->mall_id;
- $config_enter = \Yii::$app->services->setting->addons->get($this->mall_id, MchEnum::ADDONS_NAME, 'enter');
- if (1 == $config_enter['time_status']) {
- $days = $config_enter['expired_days'];
- $post['expire_time'] = time() + $days * 24 * 60 * 60;
- } else {
- $post['expire_time'] = 0;
- }
- $post['check_status'] = MchEnum::CHECK_ADOPT;
- $rr = Mch::addStore($post);
- if (false === $rr) {
- return $this->error(Mch::getStaticError());
- }
- return $this->success('添加成功');
- }
- }
- /**
- * @name:
- * @msg: 门店详情
- * @param {*}
- * @return {*}
- */
- public function actionDetail()
- {
- if (!\Yii::$app->request->isAjax) {
- return $this->render('/store/detail');
- }
- if (\Yii::$app->request->isGet) {
- $mch_id = \Yii::$app->request->get('mch_id');
- if (empty($mch_id)) {
- return $this->error('参数错误');
- }
- $store = Mch::find()
- ->where(['mall_id' => $this->mall_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED], 'id' => $mch_id])
- ->asArray()
- ->one();
- if (empty($store)) {
- return $this->error('门店不存在');
- }
- $categorys = MchCate::find()
- ->select('id,name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- $good_counts = Goods::find()
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'mch_id' => $mch_id])
- ->count();
- $cate_id_name_map = array_column($categorys, 'name', 'id');
- $store['cate_name'] = $cate_id_name_map[$store['c_id']] ?? '';
- $store['good_counts'] = $good_counts;
- $store['total_order_number'] = $store['total_num'];
- $store['unsettled_amount'] = $store['total_expenses'];
- $store['customer_service'] = empty($store['customer_service']) ? ['web_service_url' => ''] : json_decode($store['customer_service'], true);
- $basic_setting = $store;
- $store_admin = MchAdmin::findOne(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'mch_id' => $store['id']]);
- $settings = MchSettings::find()
- ->where(['mall_id' => $this->mall_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED], 'mch_id' => $mch_id])
- ->asArray()
- ->one();
- $store_setting = [
- 'shop_status' => $store['shop_status'] ?? 0,
- 'business_time_start' => $store['business_time_start'] ?? '',
- 'business_time_end' => $store['business_time_end'] ?? '',
- 'store_background' => $store['store_background'] ?? '',
- 'username' => $store_admin->username,
- 'individual_fee_setting' => $settings['individual_fee_setting'] ?? 0,
- 'store_service_fee' => $settings['store_service_fee'] ?? 0,
- 'store_service_ratio' => $settings['store_service_ratio'] ?? 10,
- 'store_settle_type' => $settings['store_settle_type'] ?? 1,
- 'store_settle_scene' => $settings['store_settle_scene'] ?? 1,
- 'is_balance_cash_service_fee' => $settings['is_balance_cash_service_fee'] ?? 0,
- 'balance_cash_service_fee' => $settings['balance_cash_service_fee'] ?? 0,
- 'store_commission_authority' => json_decode($settings['store_commission_authority'], true) ?? ['agent'=> 0, 'area'=> 0, 'boss'=>0, 'distribution'=> 0],
- ];
- /* ---------- 会员等级相关配置处理 start ------ */
- $cashier_setting = [
- 'cachier_service_ratio' => $settings['cachier_service_ratio'] ?? 10,
- 'cashier_member_status' => $settings['cashier_member_status'] ?? 0,
- 'cashier_member_settings' => $settings['cashier_member_settings'],
- 'cashier_distribution_is_enable' => $settings['cashier_distribution_is_enable'] ?? 0,
- 'cashier_distribution_settings' => $settings['cashier_distribution_settings'],
- 'cashier_agent_is_enable' => $settings['cashier_agent_is_enable'] ?? 0,
- 'cashier_agent_settings' => $settings['cashier_agent_settings'],
- 'deepNames' => ['一级分销', '二级分销'],
- ];
- $member_levels = UserLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- if (empty($member_levels)) {
- $member_levels = [
- ['level' => 0, 'level_name' => '默认等级'],
- ];
- }
- if (!empty($cashier_setting['cashier_member_settings'])) {
- $setting_members = json_decode($cashier_setting['cashier_member_settings'], true);
- $mem_levels = array_column($setting_members, 'level');
- $mem_level_discount_map = array_column($setting_members, 'discount', 'level');
- } else {
- $mem_levels = [];
- $mem_level_discount_map = [];
- }
- foreach ($member_levels as &$mlevel) {
- if (!in_array($mlevel['level'], $mem_levels)) {
- $mlevel['discount'] = 0;
- } else {
- $mlevel['discount'] = floatval($mem_level_discount_map[$mlevel['level']] ?? 0);
- }
- }
- // dd($member_levels);
- $cashier_setting['cashier_member_settings'] = $member_levels;
- /* ---------- 会员等级相关配置处理 end ------ */
- /* ---------- 分销等级相关配置处理 start ------ */
- $is_install_distribution = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_DISTRIBUTION);
- if (!$is_install_distribution) {
- $distribution_settings = [];
- $is_distribution_enable = 0;
- } else {
- $is_distribution_enable = 1;
- $distribution_levels = DistributionLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- if (empty($distribution_levels)) {
- $distribution_levels = [
- ['level' => 0, 'level_name' => '默认等级'],
- ];
- }
- if (!empty($cashier_setting['cashier_distribution_settings'])) {
- $distribution_settings = json_decode($cashier_setting['cashier_distribution_settings'], true);
- $distr_levels = array_column($distribution_settings, 'level');
- $distr_level_discount_map = array_column($distribution_settings, 'commission_rate', 'level');
- } else {
- $distr_levels = $distr_level_discount_map = [];
- }
- foreach ($distribution_levels as &$dlevel) {
- if (!in_array($dlevel['level'], $distr_levels)) {
- $dlevel['commission_rate'] = [0, 0];
- } else {
- $dlevel['commission_rate'] = $distr_level_discount_map[$dlevel['level']] ?? [0, 0];
- }
- }
- $cashier_setting['cashier_distribution_settings'] = $distribution_levels;
- $cashier_setting['is_distribution_enable'] = $is_distribution_enable;
- }
- /* ---------- 分销等级相关配置处理 end ------ */
- /* ---------- 经销等级相关配置处理 start ------ */
- $is_install_agent = MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_AGENT);
- if (!$is_install_agent) {
- $agent_settings = [
- 'team_rewards' => [
- ['level' => 0, 'level_name' => '默认等级', 'commission_rate' => 0],
- ],
- 'equal_rewards' => [
- ['level' => 0, 'level_name' => '默认等级', 'commission_rate' => 0],
- ],
- 'over_rewards' => [
- ['level' => 0, 'level_name' => '默认等级', 'commission_rate' => 0],
- ],
- ];
- $is_agent_enable = 0;
- } else {
- $is_agent_enable = 1;
- $agent_levels = AgentLevel::find()
- ->select('level,name as level_name')
- ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
- ->asArray()
- ->all();
- if (empty($agent_levels)) {
- $agent_levels = [
- ['level' => 0, 'level_name' => '默认等级'],
- ];
- }
- if (!empty($cashier_setting['cashier_agent_settings'])) {
- $agent_settings = json_decode($cashier_setting['cashier_agent_settings'], true);
- } else {
- $agent_settings = [
- 'team_rewards' => [
- ['level' => 0, 'level_name' => '默认等级', 'commission_rate' => 0],
- ],
- 'equal_rewards' => [
- ['level' => 0, 'level_name' => '默认等级', 'commission_rate' => 0],
- ],
- 'over_rewards' => [
- ['level' => 0, 'level_name' => '默认等级', 'commission_rate' => 0],
- ],
- ];
- }
- foreach ($agent_settings as $reward_name => $setting) {
- foreach ($setting as $val) {
- $agent_settings[$reward_name][$val['level']] = $val;
- }
- }
- $ag_levels = array_column($agent_settings['team_rewards'], 'level');
- $agent_level_settings = [];
- foreach ($agent_levels as $alevel) {
- if (!in_array($alevel['level'], $ag_levels)) {
- $arr = $alevel;
- $arr['commission_rate'] = 0;
- $agent_level_settings['team_rewards'][] = $arr;
- $agent_level_settings['equal_rewards'][] = $arr;
- $agent_level_settings['over_rewards'][] = $arr;
- } else {
- $arr = [
- 'level' => $alevel['level'],
- 'level_name' => $alevel['level_name'],
- 'commission_rate' => $agent_settings['team_rewards'][$alevel['level']]['commission_rate'] ?? 0,
- ];
- $agent_level_settings['team_rewards'][] = $arr;
- $arr['commission_rate'] = $agent_settings['equal_rewards'][$alevel['level']]['commission_rate'] ?? 0;
- $agent_level_settings['equal_rewards'][] = $arr;
- $arr['commission_rate'] = $agent_settings['over_rewards'][$alevel['level']]['commission_rate'] ?? 0;
- $agent_level_settings['over_rewards'][] = $arr;
- }
- }
- $cashier_setting['cashier_agent_settings'] = $agent_level_settings;
- $cashier_setting['is_agent_enable'] = $is_agent_enable;
- /* ---------- 经销等级相关配置处理 end ------ */
- }
- return $this->success('success', ['basic_setting' => $basic_setting, 'store_setting' => $store_setting, 'cashier_setting' => $cashier_setting, 'categorys' => $categorys]);
- } else {
- $post = \Yii::$app->request->post();
- $group = $post['group'];
- $mch_id = $post['mch_id'];
- if (empty($group) || !in_array($group, ['store_setting', 'cashier_setting', 'basic_setting']) || empty($mch_id)) {
- return $this->error('参数错误');
- }
- $rules = [
- 'basic_setting' => [
- [['store_name', 'logo_img', 'license_img', 'share_title', 'share_desc', 'share_pic', 'longitude', 'latitude', 'address', 'share_title', 'share_desc', 'share_pic'], 'string', 'max' => 255],
- [['shop_mobile', 'c_id','expire_time'], 'integer'],
- [['customer_service'], 'safe'],
- ],
- 'store_setting' => [
- [['shop_status', 'username', 'store_service_fee', 'store_service_ratio', 'store_settle_type', 'store_settle_scene','store_commission_authority', 'individual_fee_setting'], 'required'],
- [['shop_status', 'store_service_fee', 'store_settle_type', 'store_settle_scene','is_balance_cash_service_fee', 'individual_fee_setting'], 'integer'],
- [['store_service_ratio','balance_cash_service_fee'], 'number'],
- ['password', 'safe'],
- ],
- ];
- $res = \Yii::$app->services->validate->validate($post[$group], $rules[$group]);
- if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- $post[$group]['mch_id'] = $mch_id;
- // dd($post);
- if ('store_setting' == $group) {
- $res = MchSettings::saveStoreSetting($this->mall_id, $post[$group]);
- if (false === $res) {
- return $this->error(MchSettings::getStaticError());
- }
- return $this->success('保存成功');
- } elseif ('cashier_setting' == $group) {
- $res = MchSettings::setData($this->mall_id, $post[$group]);
- if (false === $res) {
- return $this->error(MchSettings::getStaticError());
- }
- return $this->success('保存成功');
- } elseif ('basic_setting' == $group) {
- $post[$group]['mall_id'] = $this->mall_id;
- $post[$group]['id'] = $mch_id;
- unset($post[$group]['mch_id']);
- $res = Mch::setData($post[$group]);
- if (false === $res) {
- return $this->error(Mch::getStaticError());
- }
- return $this->success('保存成功');
- }
- }
- }
- /**
- * 选择门店接口,外部调用
- * @return mixed|void
- */
- public function actionSelectMch(){
- if (\Yii::$app->request->isAjax && \Yii::$app->request->isGet) {
- $params = \Yii::$app->request->get();
- $params['where'][] = ['mall_id' => $this->mall_id];
- $params['where'][] = ['status' => [StatusEnum::ENABLED]];
- if (!empty($params['keyword'])) $params['where'][] = ['like', 'store_name', $params['keyword']];
- $params['order'] = 'id desc';
- $params['select'] = 'id,store_name,shop_owner,shop_mobile,logo_img,store_desc,shop_status,status';
- $list = Mch::listPage($params);
- return $this->success('操作成功', $list);
- }
- }
- //门店删除
- public function actionDel(){
- try {
- $params = \Yii::$app->request->post();
- Mch::delStore($this->mall_id,$params['id']);
- return $this->success();
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- }
- }
|