123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- defined('InShopNC') or exit('Access Invalid!');
- class channelControl extends SystemControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function indexOp()
- {
- $channel_list = Model('channel')->getChannelList([] , 30 , 'add_time desc');
- Tpl::output('channel_list', $channel_list);
- Tpl::output('page', Model('channel')->showpage());
- Tpl::showpage('channel.index');
- }
- public function channel_addOp()
- {
- if (chksubmit()) {
- $obj_validate = new Validator();
- $obj_validate->validateparam = [
- ["input" => $_POST["channel_name"], "require" => "true", "message" => '名称不能为空'],
- ["input" => $_POST["store"], "require" => "true", "message" => '包含店铺不能为空']
- ];
- $error = $obj_validate->validate();
- if ($error != '') {
- showMessage($error);
- } else {
- $channel_name = trim($_POST['channel_name']);
- $store = trim($_POST['store']);
- $store = trim($store , ',');
- $stores = explode(',' , $store);
- foreach ($stores as $id) {
- $store_data = Model('store')->getStoreMemberIDList($id);
- if(empty($store_data)) {
- showMessage("店铺ID为{$id}的店铺不存在");
- }
- }
- $insert_array['channel_name'] = $channel_name;
- $insert_array['store_id'] = $store;
- $insert_array['add_time'] = time();
- $model_channel = Model('channel');
- $result = $model_channel->addChannel($insert_array);
- if ($result) {
- $url = [
- [
- 'url' => 'index.php?act=channel&op=index',
- 'msg' => '返回充值商列表',
- ],
- [
- 'url' => 'index.php?act=channel&op=channel_add',
- 'msg' => '继续新增充值商',
- ],
- ];
- $this->log('添加充值商:' . '[ ' . $_POST['channel_name'] . ']', 1);
- showMessage('充值商添加成功', $url);
- } else {
- showMessage('充值商添加失败');
- }
- }
- }
- Tpl::showpage('channel.add');
- }
- public function channel_editOp()
- {
- $cid = $_GET['cid'] ?? $_POST['cid'];
- $model_channel = Model('channel');
- $channel = $model_channel->getChannelInfo(['cid' => $cid]);
- if(empty($channel)){
- showMessage('充值商信息有误');
- }
- if (chksubmit()) {
- $store = trim($_POST['store']);
- $store = trim($store , ',');
- $stores = explode(',' , $store);
- foreach ($stores as $id) {
- $store_data = Model('store')->getStoreMemberIDList($id);
- if(empty($store_data)) {
- showMessage("店铺ID为{$id}的店铺不存在");
- }
- }
- $update['channel_name'] = trim($_POST['channel_name']);
- $update['store_id'] = $store;
- $result = $model_channel->editChannel($update,['cid' => $cid]);
- if ($result) {
- $this->log('编辑充值商:' . '[ ' . $channel['channel_name'] . ']', 1);
- showMessage('充值商编辑成功', 'index.php?act=channel&op=index');
- } else {
- showMessage('充值商编辑失败', 'index.php?act=channel&op=index');
- }
- }
- Tpl::output('channel', $channel);
- Tpl::showpage('channel.edit');
- }
- }
|