getThirdProductList($condition, 50); Tpl::output('opened_text', self::STATE_TEXT); Tpl::output('third_product_type', self::THIRD_PRODUCT_TYPE); Tpl::output('product_list', $list); Tpl::output('page', $mod->showpage()); Tpl::showpage('third.product.list'); } public function changeStateOp() { $system_code = $_GET['system_code']; $opened = intval($_GET['opened']); $mod = Model('refill_third'); $third_product = $mod->findThirdProduct($system_code); if(empty($third_product)) { showMessage('产品不存在'); } if (!in_array($opened, [1, 2])) { showMessage('操作状态错误'); } $resp = $mod->editThirdProduct($system_code, ['opened' => $opened]); if (!$resp) { showMessage('操作失败'); } showMessage('操作成功'); } public function check_codeOp() { $mod = Model('thrid_refill'); $system_code = $_GET['system_code']; $product = $mod->getProduct(['system_code' => $system_code]); if (empty($product)) { echo 'true'; } else { echo 'false'; } } public function product_addOp() { if (chksubmit()) { $obj_validate = new Validator(); $obj_validate->validateparam = [ ["input" => trim($_POST["system_code"]), "require" => "true", "message" => '产品CODE不能为空'], ["input" => trim($_POST["product_type"]), "require" => "true", "message" => '产品类型不能为空'], ["input" => trim($_POST["product_name"]), "require" => "true", "message" => '产品名称不能为空'], ["input" => trim($_POST["refill_amount"]), "require" => "true", "message" => '产品面值不能为空'], ]; $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { $mod = Model('refill_third'); $insert['system_code'] = trim($_POST['system_code']); $insert['product_name'] = trim($_POST['product_name']); $insert['product_type'] = trim($_POST['product_type']); $insert['refill_amount'] = trim($_POST['refill_amount']); $result = $mod->addThirdProduct($insert); if ($result) { showMessage('添加成功', 'index.php?act=refill_third&op=index'); } else { showMessage('添加失败'); } } } Tpl::output('third_product_type', self::THIRD_PRODUCT_TYPE); Tpl::showpage('third.product.add'); } public function product_editOp() { $system_code = $_GET['system_code'] ?? $_POST['system_code']; $mod = Model('refill_third'); $third_product = $mod->findThirdProduct($system_code); if(empty($third_product)) { showMessage('产品不存在'); } if(chksubmit()) { $update_data['product_name'] = trim($_POST['product_name']); $update_data['refill_amount'] = trim($_POST['refill_amount']); $result = $mod->editThirdProduct($system_code, $update_data); if ($result) { showMessage('编辑成功', 'index.php?act=refill_third&op=index'); } else { showMessage('编辑失败'); } }else{ Tpl::output('third_product', $third_product); Tpl::showpage('third.product.edit'); } } public function third_propriceOp() { $system_code = $_GET['system_code'] ?? $_POST['system_code']; $mod = Model('refill_third'); $third_product = $mod->findThirdProduct($system_code); if(empty($third_product)) { showMessage('产品不存在'); } $condition['system_code'] = $system_code; if(!empty($_GET['store_id'])) { $condition['store_id'] = $_GET['store_id']; } $list = $mod->getProviderProductList($condition, 30); $providers = $this->providers(['type' => 3]); Tpl::output('providers', $providers); Tpl::output('product_list', $list); Tpl::output('third_product', $third_product); Tpl::output('recharge_type_text', ['直充','卡密','直充+卡密']); Tpl::output('page', $mod->showpage()); Tpl::showpage('third.proprice.list'); } public function third_proprice_addOp() { $system_code = $_GET['system_code'] ?? $_POST['system_code']; $mod = Model('refill_third'); $third_product = $mod->findThirdProduct($system_code); if(empty($third_product)) { showMessage('产品不存在'); } if (chksubmit()) { $obj_validate = new Validator(); $obj_validate->validateparam = [ ["input" => trim($_POST["store"]), "require" => "true", "message" => '通道信息不能为空'], ["input" => trim($_POST["channel_product_name"]), "require" => "true", "message" => '通道产品名称不能为空'], ["input" => trim($_POST["channel_code"]), "require" => "true", "message" => '通道code不能为空'], ["input" => trim($_POST["channel_amount"]), "require" => "true", "message" => '折扣价格不能为空'], ["input" => trim($_POST["recharge_type"]), "require" => "true", "message" => '充值类型不能为空'], ]; $error = $obj_validate->validate(); if ($error != '') { showMessage($error); } else { global $config; $store = trim($_POST['store']); $store = explode('-',$store); $store_id = $store[0]; $channel_name = $store[1]; $cfg_map = $config['third_providers']; $goods_id = 0; foreach ($cfg_map as $cfg) { if($cfg['name'] != $channel_name) continue; $goods_id = $cfg['cfg']['amount'][100][0]['goods_id']; } if(empty($goods_id)) { showMessage('商品配置有误,找不到商品ID!'); } $channel_product = Model('thrid_refill')->getProviderProduct($store_id,$goods_id,$system_code); if(!empty($channel_product)) { showMessage('此通道已关联过此产品'); } $mod = Model('refill_third'); $insert['channel_name'] = $channel_name; $insert['store_id'] = $store_id; $insert['channel_product_name'] = trim($_POST['channel_product_name']); $insert['goods_id'] = $goods_id; $insert['channel_code'] = trim($_POST['channel_code']); $insert['channel_amount'] = trim($_POST['channel_amount']); $insert['recharge_type'] = trim($_POST['recharge_type']); $insert['system_code'] = $system_code; $insert['product_type'] = $third_product['product_type']; $result = $mod->addProviderProduct($insert); if ($result) { showMessage('添加成功', "index.php?act=refill_third&op=third_proprice&system_code={$system_code}"); } else { showMessage('添加失败'); } } } else { $providers = $this->providers(['type' => 3]); Tpl::output('third_product_type', self::THIRD_PRODUCT_TYPE); Tpl::output('providers', $providers); Tpl::output('third_product', $third_product); Tpl::showpage('third.proprice.add'); } } public function third_proprice_editOp() { $system_code = $_GET['system_code'] ?? $_POST['system_code']; $mod = Model('refill_third'); $third_product = $mod->findThirdProduct($system_code); if(empty($third_product)) { showMessage('产品不存在'); } $store_id = $_GET['store_id'] ?? $_POST['store_id']; $goods_id = $_GET['goods_id'] ?? $_POST['goods_id']; $channel_product = Model('thrid_refill')->getProviderProduct($store_id,$goods_id,$system_code); if(empty($channel_product)) { showMessage('此通道关联产品不存在'); } if (chksubmit()) { $update_data = []; $update_data['channel_product_name'] = trim($_POST['channel_product_name']); $update_data['channel_code'] = trim($_POST['channel_code']); $update_data['channel_amount'] = trim($_POST['channel_amount']); $update_data['recharge_type'] = trim($_POST['recharge_type']); $result = $mod->edit_provider_product($system_code,$store_id,$goods_id,$update_data); if ($result) { showMessage('编辑成功', "index.php?act=refill_third&op=third_proprice&system_code={$system_code}"); } else { showMessage('编辑失败'); } } else { Tpl::output('third_product', $third_product); Tpl::output('channel_product', $channel_product); Tpl::showpage('third.proprice.edit'); } } }