开发文档——会员收费1期

 
介绍
 
  最新项目——会员收费,目的是要以更好的展现形式表现给用户,以及添加了新功能(会员机制)。
 
流程图
 
其中里面的demo:是通过url进行展现,里面的mst是参数,通过不同的参数进行展现。如:http://www.demo.com/?mst=1表示参数为1的demo样式。
 
展示界面(4种情况)

                       

获取折扣价格

接口说明
 

1、开通高级会员
psid=2
pstype=101
2、开通会员
psid=1
pstype=101
3、[会员/高级会员]价格信息
wiki地址:http://wiki.1verge.net/projects:premium:v2:product_rules_api#根据会员等级id获取等级信息
4、[是否是会员]
wiki地址:http://wiki.1verge.net/projects:premium:v2:verify_center_api#获取当前会员等级
5、[折扣信息]
wiki地址:http://wiki.1verge.net/projects:premium:v2:operation_api#根据用户id_服务id_服务类型_服务周期数_获得当前用户可以享受的折扣策略
6、可包月节目+有权观看+高级会员则显示“您是高级会员,可免费观看此节目”
7、仅包月节目+有权观看+高级会员提示“续费”
8、除6以外+有权观看则显示“截止日期”

可以在Premium.class.php中list_shows_by_pkgid函数下面继续封装调用函数

http请求脚本(curl或socket) 
 
<?php
function httpRequest($url, $hostName, array $params){
    $postParams = array();
    foreach ($params as $key=>$val) {
        $post_params[] = $key.'='.rawurlencode($val);
    }

    $postString = implode('&', $post_params);
    $result = '';
    if (function_exists('curl_init')) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: ' . $hostName));
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'DEMO.COM PREMIUM PHP5 Client ver: ' . phpversion());
        curl_setopt($ch, CURLOPT_TIMEOUT, 2);
        $result = curl_exec($ch);
        curl_close($ch);
    } else {
        $context = array('http' => array('method' => 'POST',
            'header' => 'Content-type: application/x-www-form-urlencoded'    . "\r\n".
            'Host: '.$hostName . "\r\n".
            'User-Agent: TEST.COM BC Test PHP5 Client ver: ' . phpversion() . "\r\n".
            'Content-length: ' . strlen($postString),
                'content' => $postString));
        $contextId = stream_context_create($context);
        $handle = fopen($url, 'r', false, $contextId);
        if ($handle) {
            while (!feof($handle)) $result .= fgets($sock, 4096);
            fclose($handle);
        }   
    }   

    return $result;
}
 
测试数据
 

1、点播信息节目ID:1e390718b72311df97c0.html
2、vip用户ID:123350942
3、普通用户ID:106738702

有权观看的节目ID:cbfb035e962411de83b1.html

 
推荐
 
原文地址:https://www.cnblogs.com/baochuan/p/2630790.html