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'); } }