软件测试自学舞蹈简单,白盒测试—被测脚本 - 舞黠_testing - 51Testing软件测试网 51Testing软件测试网-软件测试人的精神家园...

require_once( "/data/vipshop/viplib/lib/NetUtil.php"); //防止出现多次引用造成重复定义

$sellerFile = getSellerFilePath();

$sellerFile = "/data/web/shop_cm/htdocs/shop_v1/htdocs/pms/contact_static/contact_change_data.sql";

if( empty($sellerFile)){//数据文件为空情况

$ret_array['msg'] = -1;//哈希结构数据

$ret_array['msg'] = 'have no seller data' ;

return $ret_array ;

}

$sellerArray = parseSellerFileToArray($sellerFile);

foreach ($sellerArray as $eachSellerDataArray){

sendWeekGrowContact($eachSellerDataArray);

sendHighValueContact($eachSellerDataArray);

}

//发送每周环比增长的触达-------记得要加上日志

function sendWeekGrowContact(&$sellerDataArray){

$sendContent = "您好,您店铺昨日";

//$weekGrowFlag等于访问量周坏比+支付周坏比+转化率周坏比 即:1+2+4

$weekGrowFlag =  $sellerDataArray['weekGrowFlag'];

if(empty($sellerDataArray['sellerUin']) || empty($weekGrowFlag)){

return ;

}

//第一个标识位为1的时候,标识访问量周坏比达到要求

if($weekGrowFlag & 1 ){

$visitorMargin = $sellerDataArray['visitorMargin'];

if(!empty($visitorMargin)){

if($visitorMargin > 0){

$sendContent =  $sendContent."访客数 ".$sellerDataArray['visitorNum'].",比上周同期提高 ".round($sellerDataArray['visitorMargin']*100,2) ."%;";

}else{

$sendContent =  $sendContent."访客数 ".$sellerDataArray['visitorNum'].",比上周同期下降 ".round($sellerDataArray['visitorMargin']*100,2) ."%;";

}

}

}

//第二个标识位为1的时候,标识支付金额周坏比达到要求

if($weekGrowFlag & 2 ){

$paymentMargin = $sellerDataArray['paymentMargin'];

if(!empty($paymentMargin)){

if($paymentMargin > 0){

$sendContent =  $sendContent."支付金额  ".$sellerDataArray['payment'].",比上周同期提高 ".round($sellerDataArray['paymentMargin']*100,2) ."%;";

}else{

$sendContent =  $sendContent."支付金额  ".$sellerDataArray['payment'].",比上周同期下降 ".round($sellerDataArray['paymentMargin']*100,2) ."%;";

}

}

}

//第三个标识位为1的时候,标识购买转化率周环比达到要求

if($weekGrowFlag & 4 ){

$converseMargin = $sellerDataArray['converseMargin'];

if(!empty($converseMargin)){

if($converseMargin > 0){

$sendContent =  $sendContent."购买转化率  ".round($sellerDataArray['converse'],2).",比上周同期提高 ".round($sellerDataArray['converseMargin']*100,2) ."%";

}else{

$sendContent =  $sendContent."购买转化率  ".round($sellerDataArray['converse'],2).",比上周同期下降 ".round($sellerDataArray['converseMargin']*100,2) ."%";

}

}

}

//发tips的时候,不用设置&TIPSVARS

if($weekGrowFlag & 4 || $weekGrowFlag & 2 || $weekGrowFlag & 1){

$contactId = 203;//该模板id是在触达页面配置的模板生成的id

//$sendString = "id=".$contactId."&uin=".$sellerDataArray['sellerUin']."&MAILVARS=".$sendContent."&PMSVARS=".$sendContent."\r\n";

$sendString = "id=".$contactId."&uin=".$sellerDataArray['sellerUin']."&PMSVARS=".$sendContent."\r\n";

NetUtil::tcpCmd('10.130.1.46', 12015, $sendString);

}

}

//发送最高记录的触达

function sendHighValueContact(&$sellerDataArray){

$sendContent = "恭喜您!您店铺昨日";

//$weekGrowFlag等于访问量周坏比+支付周坏比+转化率周坏比 即:1+2+4

$highestHistoryFlag =  $sellerDataArray['highestHistoryFlag'];

if(empty($sellerDataArray['sellerUin'])||empty($highestHistoryFlag)){

return ;

}

//第一个标识位(2的0次方)为1的时候,标识访问量达到最高

if($highestHistoryFlag & 1 ){

$highestVistor = $sellerDataArray['highestVistor'];

if(!empty($highestVistor)){

$sendContent =  $sendContent."访客数为".$highestVistor.',达到本年度单日访客数最高记录;';

}

}

//第二个标识位(2的1次方)为1的时候,标识支付金额达到最高

if($highestHistoryFlag & 2 ){

$highestPayment = $sellerDataArray['highestPayment'];

if(!empty($highestPayment)){

$sendContent =  $sendContent."支付金额".$sellerDataArray['highestPayment'].',达到本年度单日最高记录;';

}

}

//第三个标识位(2的2次方是4)为1的时候,转化率达到最高

if($highestHistoryFlag & 4 ){

$highestConverse = $sellerDataArray['highestConverse'];

if(!empty($highestConverse)){

$sendContent =  $sendContent."转化率".$sellerDataArray['highestConverse'].',达到本年度单日最高记录';

}

}

if($highestHistoryFlag & 4 || $highestHistoryFlag & 2 || $highestHistoryFlag & 1){

$sendContent = $sendContent.'请加油再创辉煌';

$contactId = 204;//该模板id是在触达页面配置的模板生成的id

$sendString ="id=".$contactId."&uin=".$sellerDataArray['sellerUin']."&SMSVARS=".$sendContent."&PMSVARS=".$sendContent."\r\n";

NetUtil::tcpCmd('10.130.1.46', 12015, $sendString);

}

}

function parseSellerFileToArray($sellerFile){//读取生成的sql文件

$sellerResultArray = array();

$uinlist_fd = fopen($sellerFile,'r') ;

if( !$uinlist_fd ){

$ret_array['iret'] = -6 ;

$ret_array['msg']  = '读取号码包失败,请联系yiyuefu处理' ;

return $ret_array ;

}

fseek($uinlist_fd, 0);//从文件开始读取,系统接口

while(!feof( $uinlist_fd)){

$line = trim(fgets($uinlist_fd ));//空格、回车去掉后一行一行的读取

if(empty($line)){

continue;

}

$sellerDataArray = array();

$line         = str_replace(array("\r\n","\r","\n"),"\t",$line);//把每行中回车用tab代替  \t是tab  \r\n是window下回车  \r是mac下回车  \n是linux 下的回车

$field        = explode("\t", $line);//每行用\t来分割

var_dump($field);

$sellerDataArray['sellerUin']   = $field[1];

$sellerDataArray['visitorNum']   = $field[2];

$sellerDataArray['visitorMargin']  = $field[3];

$sellerDataArray['payment']    = $field[4];

$sellerDataArray['paymentMargin']  = $field[5];

$sellerDataArray['converse']     = $field[6];

$sellerDataArray['converseMargin'] = $field[7];

$sellerDataArray['weekGrowFlag']   = $field[8];

$sellerDataArray['highestVistor']    = $field[9];

$sellerDataArray['highestPayment']   = $field[10];

$sellerDataArray['highestConverse']  = $field[11];

$sellerDataArray['highestHistoryFlag']= $field[12];

//这里不做去重了,在数据库中做去重工作

array_push($sellerResultArray,$sellerDataArray);

}

fclose( $uinlist_fd );

return $sellerResultArray ;

}

//返回一个解压缩后的数据文件

function getSellerFilePath(){

//2011/06/27 04:27:37"

$yestedayString=  date("Y/m/d h:i:s",time()-24*60*60);//格式化当前时间对应的昨天时间

$strtimes = explode(" ",$yestedayString);//空格分割时间为数组

$timearray = explode("/",$strtimes[0]);//把第一个数组变成2011/06/27

$tempfilePath = "";

foreach($timearray as $value){//遍历数组中每个元素,再换成字符串

$tempfilePath = $tempfilePath.$value; //.表示把字符串连接起来

}

$gizFilePath =sprintf("/data/web/shop_cm/htdocs/shop_v1/htdocs/pms/shopDataChange/paipai_%s_c2c_r_pms_data_change.txt.gz",$tempfilePath);

$finallyfilePath = sprintf("/data/web/shop_cm/htdocs/shop_v1/htdocs/pms/shopDataChange/paipai_%s_c2c_r_pms_data_change.txt",$tempfilePath);

if(file_exists($gizFilePath)){

exec('gzip -d '.$gizFilePath) ;//.表示把字符串连接起来

var_dump($finallyfilePath);//调试把解压缩后的文件打印到终端

return $finallyfilePath;

}else{

return "";//如果压缩文件不存在,就返回空

}

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值