execute($sql, [$params['agentid'], $params['name'], 10000000, $params['power']]); } /** * 添加新渠道,并添加相应的产品 * @param $p */ public function addChannel(&$p) { $sql = 'insert into ct_channel_list ( agent_id, channel_id, nickname, logo, qq, is_show_recharge_star, recharge_roomcard_to_sales, wechat, app_id, devkey, market_id, app_id_pay, devkey_pay, market_id_pay, is_open, parent_agent_id, become_sales_mode, invitation_model, buy_card_mode, is_check_phone) VALUES ( ?,?,?,?,?, ?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?,0 )'; $this->execute($sql, [ $p['agentid'], $p['channelid'], $p['name'], $p['logo'], $p['qq'], $p['is_show_recharge_star'], $p['recharge_roomcard_to_sales'], $p['wechat'], '14966338932488', '14966329712475', 'ylhdyx', '14966338932488', '14966329712475', 'ylhdyx', $p['is_open'], $p['parentid'], $p['become_sales_mode'], $p['invitation_model'], $p['buy_card_mode'] ]); // 添加产品 $agent_id = $p['agentid']; $sql = <<execute($sql); } /** * 添加游戏 * @param $p */ public function addGame(&$p) { $sql = 'insert into ct_game_list ( channel_id, game_id, game_name, logo, description, ios_download_url, ios_market_type, ios_app_size, android_download_url, android_app_size, is_open ) VALUES ( ?,?,?,?,?, ?,?,?,?,?, ? );'; $this->execute($sql, [ $p['channelid'], $p['gameid'], $p['gamename'], $p['logo'], $p['description'], $p['ios_download_url'], $p['ios_market_type'], $p['ios_app_size'], $p['android_download_url'], $p['android_app_size'], $p['is_open'] ]); } /** * 修改代理商信息 * @param $p */ public function setAgentInfo(&$p) { $sql = 'update ct_agent_list set agent_id=?, nickname=?, default_sales_power=? where id=?; '; $this->execute($sql, [ $p['agentid'], $p['name'], $p['power'], $p['id'] ]); } /** * 修改渠道信息 * @param $p */ public function setChannelInfo(&$p) { $sql = 'update ct_channel_list set agent_id=?, channel_id=?, nickname=?, logo=?, qq=?, is_show_recharge_star=?, recharge_roomcard_to_sales=?, wechat=?, is_open=?, parent_agent_id=?, become_sales_mode=?, invitation_model=?, buy_card_mode=?, share_title=?, share_desc=?, share_img=?, share_text=?, pay_desc=?, announcement=? where id=?; '; $this->execute($sql, [ $p['agentid'], $p['channelid'], $p['name'], $p['logo'], $p['qq'], $p['is_show_recharge_star'], $p['recharge_roomcard_to_sales'], $p['wechat'], $p['is_open'], $p['parentid'], $p['become_sales_mode'], $p['invitation_model'], $p['buy_card_mode'], $p['share_title'], $p['share_desc'], $p['share_img'], $p['share_text'], $p['pay_desc'], $p['announcement'], $p['id'] ]); } /** * 修改渠道信息 * @param $p */ public function setGameInfo(&$p) { $sql = 'update ct_game_list set channel_id=?, game_id=?, game_name=?, logo=?, description=?, ios_download_url=?, ios_market_type=?, ios_app_size=?, android_download_url=?, android_app_size=?, is_open=? where id=?; '; $this->execute($sql, [ $p['channelid'], $p['gameid'], $p['gamename'], $p['logo'], $p['description'], $p['ios_download_url'], $p['ios_market_type'], $p['ios_app_size'], $p['android_download_url'], $p['android_app_size'], $p['is_open'], $p['id'] ]); } /** * 获取相关联的渠道列表 * @param $params * @return array */ public function getChannelList(&$params) { // 获取所有开放的渠道 if($params['agentid'] === 'all') { $sql = /** @lang text */ 'SELECT id, agent_id AS agentid, channel_id AS channelid, nickname AS name FROM ct_channel_list WHERE is_open = 1;'; } else { $sql = /** @lang text */ 'SELECT id, agent_id AS agentid, channel_id AS channelid, nickname AS name FROM ct_channel_list WHERE parent_agent_id = ? AND is_open = 1;'; } $result = $this->queryAll($sql, [$params['agentid']]); return $result; } /** * 获取所有渠道 * @return array */ public function getAllAgentList() { $sql = /** @lang text */'select id, agent_id as agentid, nickname as name, max_sales_id, default_sales_power from ct_agent_list;'; $result = $this->queryAll($sql); return $result; } /** * 获取所有渠道 * @return array */ public function getAllChannelList() { $sql = 'select id, agent_id as agentid, channel_id as channelid, nickname as name, parent_agent_id from ct_channel_list where is_open=1;'; $result = $this->queryAll($sql); return $result; } /** * 获取所有游戏 * @return array */ public function getAllGameList() { $sql = 'select id, channel_id as channelid, game_id as gameid, game_name as name from ct_game_list where is_open=1 order by channelid, id;'; $result = $this->queryAll($sql); return $result; } /** * 获取渠道配置信息,公共版 * @param $params * @return mixed */ public function getChannelConfig(&$params) { $sql = 'SELECT id, agent_id, channel_id, nickname AS agentname, logo AS agentlogo, qq, wechat AS channelwechat, become_sales_mode AS html_applysales, invitation_model AS agentmode, buy_card_mode AS html_buyroomcard, recharge_roomcard_to_sales, request_star, is_check_phone, create_withdrawals_order_type, create_withdrawals_order_qcode, is_show_topsales_menu, is_show_recharge_star, share_title, share_desc, share_img, share_text, pay_desc, app_id AS youle_appid, devkey AS youle_devkey, market_id AS youle_busiid, app_id_pay AS youle_appid_pay, devkey_pay AS youle_devkey_pay, market_id_pay AS youle_busiid_pay FROM ct_channel_list WHERE agent_id = ? AND channel_id = ? AND is_open = 1;'; $result = $this->query($sql, [$params['agentid'], $params['channelid']]); return $result; } /** * 获取渠道配置信息,公共版 * @param $id * @return mixed */ public function getChannelConfigById($id) { $sql = 'SELECT id, agent_id, channel_id, nickname AS agentname, logo AS agentlogo, qq, wechat AS channelwechat, become_sales_mode AS html_applysales, invitation_model AS agentmode, buy_card_mode AS html_buyroomcard, recharge_roomcard_to_sales, request_star, share_title, share_desc, share_img, share_text, pay_desc, app_id AS youle_appid, devkey AS youle_devkey, market_id AS youle_busiid, app_id_pay AS youle_appid_pay, devkey_pay AS youle_devkey_pay, market_id_pay AS youle_busiid_pay FROM ct_channel_list WHERE id=? AND is_open = 1;'; $result = $this->query($sql, [$id]); return $result; } /** * 获取代理商配置信息,管理员版 * @param $p * @return mixed */ public function getAgentInfo(&$p) { $sql = 'SELECT agent_id as agentid, nickname as name, default_sales_power as power FROM ct_agent_list WHERE id=?;'; $result = $this->query($sql, [$p['id']]); return $result; } /** * 获取渠道配置信息,管理员版 * @param $p * @return mixed */ public function getChannelInfo(&$p) { $sql = 'SELECT agent_id as agentid, channel_id as channelid, parent_agent_id as parentid, nickname AS name, logo, qq, wechat, is_show_recharge_star, recharge_roomcard_to_sales, become_sales_mode, invitation_model, buy_card_mode, request_star, share_title, share_desc, share_img, share_text, pay_desc, announcement, is_open FROM ct_channel_list WHERE id=?;'; $result = $this->query($sql, [$p['id']]); return $result; } /** * 获取游戏配置信息,管理员版 * @param $p * @return mixed */ public function getGameInfo(&$p) { $sql = 'SELECT channel_id as channelid, game_id as gameid, game_name as gamename, logo, description, ios_download_url, ios_market_type, ios_app_size, android_download_url, android_app_size, is_open FROM ct_game_list WHERE id=?;'; $result = $this->query($sql, [$p['id']]); return $result; } /** * 获取游戏下载列表 * @param $params * @return array */ public function getGameList(&$params) { $sql = 'SELECT game_id, game_name AS name, logo AS image, description AS memo, ios_download_url AS ios_down, ios_download_url_2 AS ios_down_2, ios_market_type AS ios_marketid, ios_app_size AS ios_size, android_download_url AS android_down, android_download_url_2 AS android_down_2, android_app_size AS android_size FROM ct_game_list WHERE channel_id = ? AND is_open = 1;'; $result = $this->queryAll($sql, [$params['channelid']]); return $result; } /** * 产品列表 * @param $params * @return array */ public function getProductList(&$params) { /** * sales_product 表 * sapr_type => 0-针对个人玩家的产品 1-针对个人代理的产品 * product_type => 0-房卡,1-星星,2-钻石 * sapr_state => 0-启用 1-禁用 * sort 排序(数值大的在前面) */ $sql = 'SELECT idx as productid, sapr_name as name, sapr_amount as amount, sapr_money as money, sapr_memo as memo, product_type, sapr_type as type, make_vip FROM sales_product WHERE sapr_agentid = ? and sapr_type = ? and product_type = ? and sapr_state = 0 and parent_id is null ORDER BY sort desc, idx;'; $result = $this->queryAll($sql, [$params['agentid'], $params['type'], $params['ptype']]); return $result; } /** * 获取指定渠道所有商品 * @param $agent_id * @return array * @throws \Exception */ public function getAllProductList($agent_id) { $sql = 'select * from sales_product where sapr_agentid=? order by product_type, sort desc'; return $this->queryAll($sql, [$agent_id]); } /** * 获取单个商品信息 * @param $id * @return mixed * @throws \Exception */ public function getProductInfo($id) { $sql = 'select * from sales_product where idx=?'; return $this->query($sql, $id); } /** * 修改商品信息 * @param $p * @throws \Exception */ public function setProductInfo($p) { if(empty($p['parent_id'])) $parent_id = null; else $parent_id = $p['parent_id']; $sql = 'update sales_product set sapr_agentid=?, sapr_type=?, sapr_name=?, sapr_amount=?, sapr_money=?, sapr_memo=?, sapr_state=?, product_type=?, parent_id=?, sort=?, make_vip=? where idx=?'; $this->execute($sql, [ $p['sapr_agentid'], $p['sapr_type'],$p['sapr_name'],$p['sapr_amount'],$p['sapr_money'], $p['sapr_memo'], $p['sapr_state'],$p['product_type'],$parent_id,$p['sort'], $p['make_vip'],$p['idx'] ]); } /** * 添加商品 * @param $p * @throws \Exception */ public function addProductInfo($p) { if(empty($p['parent_id'])) $parent_id = null; else $parent_id = $p['parent_id']; $sql = 'insert into sales_product ( sapr_agentid, sapr_type, sapr_name, sapr_amount, sapr_money, sapr_memo, sapr_state, product_type, parent_id, sort, make_vip ) values ( ?,?,?,?,?, ?,?,?,?,?, ?)'; $this->execute($sql, [ $p['sapr_agentid'], $p['sapr_type'],$p['sapr_name'],$p['sapr_amount'],$p['sapr_money'], $p['sapr_memo'], $p['sapr_state'],$p['product_type'],$parent_id,$p['sort'], $p['make_vip'] ]); } /** * 使用钻石兑换的商品 * @param $params * @return array * @throws \Exception */ public function getTransformProductList(&$params) { $sql = /** @lang text */<<queryAll($sql, [$params['agentid'], $params['channelid']]); $result = $this->queryAll($sql, [$params['agentid'], $params['channelid'], $params['agentid'], $params['channelid']]); return $result; } /** * 公告 * type => 0-代理后台的公告 1-代理抽成的公告 * @param $p * @return array */ public function getNotice(&$p) { $sql = 'SELECT notice_info FROM ct_agent_notice WHERE (channel_id=1 or channel_id=?) and type=? and status=1;'; $result = $this->queryAll($sql, [$p['channelid'], $p['type']]); return isset($result[0]) ? $result[0] : ['notice_info' => '']; } /** * 获取茶水费配置 * @param $p * @return array */ public function getAgentServiceConfig(&$p) { $sql = 'select * from ct_agent_service where agent_id=? and channel_id=?;'; $result = $this->queryAll($sql, [$p['agentid'], $p['channelid']]); return $result; } /** * 单个茶水费配置 * @param $id * @return array */ public function getAgentServiceConfigSingle($id) { $sql = 'select * from ct_agent_service where id=?;'; $result = $this->query($sql, [$id]); return $result; } /** * 单个茶水费配置 * @param $p * @return array */ public function getAgentServiceConfigSave(&$p) { $sql = 'update ct_agent_service set min_value=?, max_value=?, `type`=?, `value`=? where id=?;'; $this->execute($sql, [$p['min_value'], $p['max_value'], $p['type'], $p['value'], $p['id']]); } }