收藏
回答

【有偿】企业付款到零钱修改为商家转账到零钱,代码PHP,API2升级为API3,有熟悉的大佬吗?

企业付款到零钱是走API2方式,商家转账到零钱走API3

两者区别如图:

目前PHP代码如下:

<?php


defined('IN_IA') or exit('Access Denied');


class zhiwu55cn_watchvideoModuleSite extends WeModuleSite {


	private function hzw_mc_fansinfo($openid,$update=false) // 如果updatetrue,更新时间超过12小时,就获取最新的头像


	{


		global $_W,$_GPC;


		if(empty($openid))


		{


			$openid=$_W['openid'];


		}


		$hzwUserInfo=pdo_get('mc_mapping_fans',array('openid'=>$openid));


		if($update)


		{


			$updatetime=$hzwUserInfo['updatetime'];


			if(is_numeric($updatetime) && $updatetime>0)


			{


				$diffTime=time();


				$diffTime=$diffTime-$updatetime;


			} else {


				$diffTime=0;


			}


			if($diffTime>300 || empty($updatetime) || empty($hzwUserInfo['nickname']))


			{


				mc_oauth_account_userinfo();


			}


		}


		$hzwUserInfo['tag']=iunserializer(base64_decode($hzwUserInfo['tag']));


		$hzwUserInfo['headimgurl']=$hzwUserInfo['tag']['headimgurl'];


		$hzwUserInfo['avatar']=$hzwUserInfo['tag']['avatar'];


		$hzwUserInfo['nickname']=$hzwUserInfo['tag']['nickname'];


		$_W['fans']['headimgurl']=$hzwUserInfo['tag']['avatar'];


		$_W['fans']['nickname']=$hzwUserInfo['tag']['nickname'];


		$_W['fans']['tag']['avatar']=$hzwUserInfo['tag']['avatar'];


		$_W['fans']['tag']['nickname']=$hzwUserInfo['tag']['nickname'];


		if(empty($hzwUserInfo['headimgurl']) && !empty($hzwUserInfo['uid']) && $hzwUserInfo['uid']>0)


		{


			$memberInfo=pdo_get('mc_members',array('uid'=>$hzwUserInfo['uid']));


			$hzwUserInfo['headimgurl']=$memberInfo['avatar'];


			$hzwUserInfo['avatar']=$memberInfo['avatar'];


			$hzwUserInfo['nickname']=$memberInfo['nickname'];


			$hzwUserInfo['tag']['nickname']=$memberInfo['nickname'];


			$hzwUserInfo['tag']['headimgurl']=$memberInfo['avatar'];


			$hzwUserInfo['tag']['avatar']=$memberInfo['avatar'];


			$_W['fans']['headimgurl']=$memberInfo['avatar'];


			$_W['fans']['nickname']=$memberInfo['nickname'];


			$_W['fans']['tag']['avatar']=$memberInfo['avatar'];


			$_W['fans']['tag']['nickname']=$memberInfo['nickname'];


		}


		return $hzwUserInfo;


	}


	public function doMobileHzwLbs() { //读取lbs地理位置






		global $_W, $_GPC;


		$settings=$this->module['config'];


		$ajaxUrl=$this->createMobileUrl("HzwLbs",array('id2'=>$_GPC['id2']));


		$backUrl = murl('entry',array('do'=>'Zhiwu55comEnter','m'=>$this->modulename,'id2'=>$_GPC['id2']),true,true);


		if(!empty($_GPC["latitude"]) && !empty($_GPC["longitude"]))


		{


			$latitude=$_GPC["latitude"];


			$longitude=$_GPC["longitude"];


			$lbs_md5_hash=$latitude.$longitude;


			$lbs_md5_hash=md5($lbs_md5_hash);


			$openid=$_W['openid'];


			if(is_numeric($latitude)==true && is_numeric($longitude)==true)


			{


				$addressTxt=file_get_contents("https://apis.map.qq.com/ws/geocoder/v1/?location=" . $latitude . "," . $longitude . "&key=3L6BZ-C2MW2-XF5UL-CIVG4-B3KLE-HHFJR&get_poi=1");


				if(empty($addressTxt))


				{


					load()->func('communication');


					$response = ihttp_get("https://apis.map.qq.com/ws/geocoder/v1/?location=" . $latitude . "," . $longitude . "&key=3L6BZ-C2MW2-XF5UL-CIVG4-B3KLE-HHFJR&get_poi=1");


					$addressTxt = $response['content'];


				}


				$addressArr=json_decode($addressTxt,true);


				if(is_array($addressArr))


				{


					$address = 	$addressArr['result']['address'];


					if(!empty($address))


					{


						$address='中国'.$address;


					}


				}


				pdo_update("zhiwu55cn_watchvideo_money",array('lbs_latitude'=>$latitude,'lbs_longitude'=>$longitude,'lbs_md5_hash'=>$lbs_md5_hash,'lbs_detail'=>$address),array('uniacid'=>$_W['uniacid'],'openid'=>$_W['openid']));


				echo 'yes';






			} else {






				echo "no";






			}


			exit;


		}


		include $this->template('Hzwlbs');


	}


	public function doWebZhiwu55statistics()


	{


		global $_W, $_GPC;


		$month=date("n",time());


		$day=date("j",time());


		$year=date("Y",time());


		$today_startTime=mktime(0,0,0,$month,$day,$year);   // 今天0点开始时间戳


		$today_endTime=mktime(0,0,0,$month,($day+1),$year); // 今天24点结束时间戳


		$today_endTime--;


		$yesterday_startTime=mktime(0,0,0,$month,($day-1),$year); // 昨天0点开始时间戳


		$yesterday_endTime=mktime(0,0,0,$month,$day,$year);	// // 昨天24点结束时间戳


		$yesterday_endTime--;


		$num1=pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE uniacid=".$_W["uniacid"]." AND (dateline BETWEEN ".$today_startTime." AND ". $today_endTime .")"); // 今天访问人数


		$num2=pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE uniacid=".$_W["uniacid"]." AND (dateline BETWEEN ".$yesterday_startTime." AND ". $yesterday_endTime .")"); // 昨天访问人数


		$num3=pdo_fetchcolumn("SELECT SUM(money) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE return_msg='SUCCESS' AND uniacid=".$_W["uniacid"]); // 观看视频发放红包总金额


		if(empty($num3))


		{


			$num3=0;






		} else {






			$num3=$num3/100;


		}


		$num4=pdo_fetchcolumn("SELECT SUM(share_openid_money) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE share_openid_return_msg='SUCCESS' AND uniacid=".$_W["uniacid"]); // 分享转发奖励红包总金额


		if(empty($num4))


		{


			$num4=0;






		} else {






			$num4=$num4/100;


		}


		$money1Arr=array();


		for($i=0;$i<=7;$i++) // 最近7天的观看视频发放金额


		{


			$startTime=$today_startTime - ($i * 86400);


			$endTime=$startTime + 86400;


			$endTime--;


			$tempNum=pdo_fetchcolumn("SELECT SUM(money) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE return_msg='SUCCESS' AND uniacid=".$_W["uniacid"]." AND (return_msg_dateline BETWEEN ".$startTime." AND ". $endTime .")");


			if(empty($tempNum))


			{


				$tempNum=0;


			} else {


				$tempNum=$tempNum/100;


			}


			$money1Arr[]=array('money'=>$tempNum,'date'=>date('Y-m-d',$startTime));


		}


		$money2Arr=array();


		for($i=0;$i<=7;$i++) // 最近7天的分享转发的推广者奖励金额


		{


			$startTime=$today_startTime - ($i * 86400);


			$endTime=$startTime + 86400;


			$endTime--;


			$tempNum=pdo_fetchcolumn("SELECT SUM(share_openid_money) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE share_openid_return_msg='SUCCESS' AND uniacid=".$_W["uniacid"]." AND (share_openid_dateline BETWEEN ".$startTime." AND ". $endTime .")");


			if(empty($tempNum))


			{


				$tempNum=0;


			} else {


				$tempNum=$tempNum/100;


			}


			$money2Arr[]=array('money'=>$tempNum,'date'=>date('Y-m-d',$startTime));


		}


		include $this->template('Zhiwu55statistics');


	}


	public function doWebZhiwu55detail()


	{


		global $_W, $_GPC;


		$Zhiwu55detailUrl=$this->createWebUrl('Zhiwu55detail');


		$Zhiwu55createUrl=$this->createWebUrl('Zhiwu55create');


		if(is_numeric($_GPC['del_id']))


		{


			pdo_delete('zhiwu55cn_watchvideo_money',array('id'=>$_GPC['del_id'],'uniacid'=>$_W['uniacid']));


			message("删除成功!","referer","success");


		}


		if(is_numeric($_GPC['share_id'])) // 推广者红包


		{


			$dataArr=pdo_get('zhiwu55cn_watchvideo_money',array('id'=>$_GPC['share_id'],'uniacid'=>$_W['uniacid']));


			if($dataArr['share_openid_return_msg']=='SUCCESS')


			{


				message("分享转发的推广奖励红包已经发放!","referer","error");


			}


			if(empty($dataArr['share_openid']) || $dataArr['share_openid_return_msg']=='hzw_no')


			{


				message("没有推广奖励红包发放","referer","error");


			}


			$dataArr2=pdo_get('zhiwu55cn_watchvideo',array('id'=>$dataArr['set_id'],'uniacid'=>$_W['uniacid']));


			if(!empty($dataArr['share_openid']) && !empty($dataArr2['share_money_min']) && !empty($dataArr2['share_money_max']) && !empty($dataArr2['share_money_desc']))


			{


				$dataArr2['share_openid']=$dataArr['share_openid'];


				$dataArr2['share_openid_money']=rand($dataArr2['share_money_min'],$dataArr2['share_money_max']);


				$shareResult=$this->send_share_money($dataArr2);


				$result=pdo_update('zhiwu55cn_watchvideo_money',array('share_openid_money'=>$dataArr2['share_openid_money'],'share_openid_return_msg'=>$shareResult,'share_openid_dateline'=>time()),array('id'=>$_GPC['share_id'],'uniacid'=>$_W['uniacid']));


				if(empty($result))


				{


					message("数据库出错!");






				} elseif($shareResult!='SUCCESS') {






					message("发放失败<br><br>".$shareResult);






				} elseif($shareResult=='SUCCESS') {






					message("发放成功","referer","success");






				} else {






					message($shareResult);






				}






			} else {






				message("推广奖励红包配置有错误,请检查!","referer","error");






			}






		}


		if(is_numeric($_GPC['send_money_id']))


		{


			$dataArr=pdo_get('zhiwu55cn_watchvideo_money',array('id'=>$_GPC['send_money_id'],'uniacid'=>$_W['uniacid']));


			if($dataArr['return_msg']=='SUCCESS')


			{


				message("观看视频红包已经发放!!","referer","error");


			}


			$dataArr2=pdo_get('zhiwu55cn_watchvideo',array('id'=>$dataArr['set_id'],'uniacid'=>$_W['uniacid']));


			$dataArr2['openid']=$dataArr['openid'];


			if(!empty($dataArr['share_openid']) && empty($dataArr["share_openid_return_msg"]) && !empty($dataArr2['share_money_min']) && !empty($dataArr2['share_money_max']) && !empty($dataArr2['share_money_desc']))


			{


				$dataArr2['share_openid']=$dataArr['share_openid'];


				$dataArr2['share_openid_money']=rand($dataArr2['share_money_min'],$dataArr2['share_money_max']);






			}


			if(empty($dataArr['money']))


			{


				$dataArr2['money']=rand($dataArr2['money_min'],$dataArr2['money_max']);


				pdo_update('zhiwu55cn_watchvideo_money',array('money'=>$dataArr2['money']),array('id'=>$_GPC['send_money_id'],'uniacid'=>$_W['uniacid']));






			} else {






				$dataArr2['money']=$dataArr['money'];






			}


			$sendResultArr=$this->send_money($dataArr2);


			$updateArr=array();


			$updateArr['return_msg']=$sendResultArr['return_msg'];


			$updateArr['return_msg_dateline']=time();


			$updateArr['share_openid_return_msg']=$sendResultArr['share_return_msg'];


			if(!empty($dataArr2['share_openid_money']))


			{


				$updateArr['share_openid_money']=$dataArr2['share_openid_money'];


			}


			$updateArr['share_openid_dateline']=time();


			$result=pdo_update('zhiwu55cn_watchvideo_money',$updateArr,array('id'=>$_GPC['send_money_id'],'uniacid'=>$_W['uniacid']));


			if(empty($result))


			{


				message("发放失败!<br><br>".$sendResult);






			} elseif($sendResultArr['return_msg']!='SUCCESS') {






				message("看观视频红包发放失败<br><br>".$sendResultArr['return_msg'],"referer","error");






			} elseif($sendResultArr['share_return_msg']!='SUCCESS' && $sendResultArr['share_return_msg']!='hzw_no') {






				message("转发分享推广者的红包发放失败<br><br>".$sendResultArr['share_return_msg'],"referer","error");






			} else {






				message("红包发放成功!","referer","success");


			}


		}


		if(empty($_GPC['page']) || is_numeric($_GPC['page'])==false)


		{


			$page=1;


		} else {


			$page=$_GPC['page'];


		}


		$page=max(1,$page);


		$startNum=($page-1) * 15;


		$total=pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('zhiwu55cn_watchvideo_money') . " WHERE uniacid=" . $_W['uniacid']);


		$list=pdo_fetchall("SELECT * FROM " . tablename('zhiwu55cn_watchvideo_money') . "  WHERE uniacid=:uniacid ORDER BY id DESC LIMIT ".$startNum.",15",array(':uniacid'=>$_W['uniacid']));


		$pagestr=pagination($total,$page,15);


		include $this->template("Zhiwu55detail");


	}


	public function doWebZhiwu55Help()


	{


		global $_W, $_GPC;


		$version = $this->module['version'];


		include $this->template("Zhiwu55Help");


	}


	public function doWebZhiwu55admin() // 管理视频


	{


		global $_W, $_GPC;


		$this->doWebZhiwu55create();


	}


	public function doWebZhiwu55createVideo() // 创建视频


	{


		global $_W, $_GPC;


		$_GPC['add_form']='yes';


		$this->doWebZhiwu55create();


	}


	public function doWebZhiwu55create()


	{


		global $_W, $_GPC;


		$Zhiwu55createUrl=$this->createWebUrl("Zhiwu55create");


		if(!empty($_GPC['create']) && $_GPC['create']=='yes')


		{






			if(stripos($_POST['content'],'_hzw_video_tag_')===false)


			{


				message("请在内容中,插入视频标签!","","error");


			}


			if(stripos($_POST['content'],'_hzw_receive_money_button_')===false)


			{


				message("请在内容中,插入领取按钮标签!","","error");


			}


			$addData=array();


			$start_time=trim($_GPC['start_time']);


			$start_time=strtotime($start_time);


			$end_time=trim($_GPC['end_time']);


			$end_time=strtotime($end_time);


			if(is_numeric($start_time) && $start_time!=$end_time)


			{


				$addData['start_time']=$start_time;


			}


			if(is_numeric($end_time) && $start_time!=$end_time)


			{


				$addData['end_time']=$end_time;


			}


			$addData['uniacid']=$_W['uniacid'];


			$addData['only_lbs']=trim($_GPC['only_lbs']);


			$addData['only_lbs']=str_ireplace(',',',',$addData['only_lbs']);


			$addData['money_count']=trim($_GPC['money_count']);


			$addData['top_title']=trim($_GPC['top_title']);


			$addData['mark_info']=trim($_GPC['mark_info']);


			$addData['follow']=trim($_GPC['follow']);


			$addData['shop_name']=trim($_GPC['shop_name']);


			$addData['shop_lbs_value']=trim($_GPC['shop_lbs_value']);


			$addData['address']=trim($_GPC['address']);


			$addData['phone']=trim($_GPC['phone']);


			$addData['shop_homepage']=trim($_GPC['shop_homepage']);


			$addData['money_type']=trim($_GPC['money_type']);


			$addData['nick_name']=trim($_GPC['nick_name']);


			$addData['send_name']=trim($_GPC['send_name']);


			$addData['wishing']=trim($_GPC['wishing']);


			$addData['act_name']=trim($_GPC['act_name']);


			$addData['remark']=trim($_GPC['remark']);


			$addData['scene_id']=trim($_GPC['scene_id']);


			$addData['money_desc']=trim($_GPC['money_desc']);


			$addData['auto_money']=trim($_GPC['auto_money']);


			$addData['share_title']=trim($_GPC['share_title']);


			$addData['share_desc']=trim($_GPC['share_desc']);


			$addData['share_logo']=trim($_GPC['share_logo']);


			$addData['video_url']=trim($_GPC['video_url']);


			$addData['video_cover']=trim($_GPC['video_cover']);


			$addData['video_time']=trim($_GPC['video_time']);


			$addData['video_css']=trim($_GPC['video_css']);


			$addData['video_btn_name']=trim($_GPC['video_btn_name']);


			$addData['video_click_redirect']=trim($_GPC['video_click_redirect']);


			$addData['video_filename']=random(32);


			$id2=random(32);


			$addData['money_min']=trim($_GPC['money_min']);


			$addData['money_min']=$addData['money_min'] * 100;


			$addData['money_max']=trim($_GPC['money_max']);


			$addData['money_max']=$addData['money_max'] * 100;


			if(is_numeric($_GPC['share_money_min']))


			{


				$addData['share_money_min']=trim($_GPC['share_money_min']);


				$addData['share_money_min']=$addData['share_money_min'] * 100;


			}


			if(is_numeric($_GPC['share_money_max']))


			{


				$addData['share_money_max']=trim($_GPC['share_money_max']);


				$addData['share_money_max']=$addData['share_money_max'] * 100;


			}


			$addData['share_money_desc']=trim($_GPC['share_money_desc']);


			$addData['create_dateline']=time();


			$addData['id2']=$id2;


			$result=pdo_insert('zhiwu55cn_watchvideo',$addData);


			if(empty($result))


			{


				message("创建失败!","","error");


			}


			$ser_id=pdo_insertid();


			$ser_id=str_pad($ser_id,5,'0',STR_PAD_LEFT);


			$qr_file=IA_ROOT.'/addons/zhiwu55cn_watchvideo/qr_file';


			if(!is_dir($qr_file))


			{


				@mkdir($qr_file);


			}


			$qr_file=$qr_file.'/'.$id2.'.png';


			if(!empty($result) && !file_exists($qr_file))


			{


				load()->library('qrcode');


				$qrUrl = murl('entry',array('do'=>'Zhiwu55comEnter','m'=>$this->modulename,'id2'=>$id2),true,true);


				QRcode::png($qrUrl,$qr_file,QR_ECLEVEL_L,10);


			}


			if(file_exists($qr_file))


			{


				include_once IA_ROOT .'/addons/zhiwu55cn_watchvideo/poster/poster.class.php';


				list($width,$height) = getimagesize($qr_file);


				// $QR_width=$item['center_logo_size'];


				// $QR_left=($width/2)-($QR_width/2);


				$imageArr=array();


				/*


				if(!empty($item['center_logo']) && is_numeric($item['center_logo_size'])) // 二维码中间图标


				{


					$center_logo=array(


									'name' => 'center_logo', //图片名称,用于出错时定位


									'url' => tomedia($item['center_logo']),


									'stream' => 0, //图片资源是否是字符串图像流


									'left' => $QR_left,


									'top' => $QR_left,


									'right' => 0,


									'bottom' => 0,


									'width' => $QR_width,


									'height' => $QR_width,


									'radius' => ($QR_width/2),


									'opacity' => 100


								);


					$imageArr[]=$center_logo;


				}


				*/


				$config = array(


					'bg_url' => $qr_file,//海报底图


					'text' => array(


									array(


										'text' => $ser_id, //显示文本


										'left' => 'center', //左边距,数字或者center,水平居中


										'top' => ($height-8), //上边距,数字或者center,垂直居中


										'width' => 0, //文本框宽度,设置后可实现文字换行


										'fontSize' => 16, //字号


										'fontPath' => 'simhei.ttf', //字体文件


										'fontColor' => '204,204,204', //字体颜色


										'angle' => 0, //倾斜角度


									)


							),


					'image' => $imageArr


				);


				poster::setConfig($config);


				$res = poster::make($qr_file);


				poster::clear();


			}


			load()->func('file');


			file_write('./zhiwu55cn_watchvideo/'.$addData['video_filename'],$_POST['content']);


			message("创建成功",$this->createWebUrl("Zhiwu55admin"),"success");






		} elseif(!empty($_GPC['smt_modify'])) {






			if(stripos($_POST['content'],'_hzw_video_tag_')===false)


			{


				message("请在内容中,插入视频标签!","","error");


			}


			if(stripos($_POST['content'],'_hzw_receive_money_button_')===false)


			{


				message("请在内容中,插入领取按钮标签!","","error");


			}


			$modifyData=array();


			$start_time=trim($_GPC['start_time']);


			$end_time=trim($_GPC['end_time']);


			$start_time=strtotime($start_time);


			$end_time=strtotime($end_time);


			if(is_numeric($start_time))


			{


				$modifyData['start_time']=$start_time;


			} else {


				$modifyData['start_time']=0;


			}


			if(is_numeric($end_time))


			{


				$modifyData['end_time']=$end_time;


			} else {


				$modifyData['end_time']=0;


			}


			$modifyData['only_lbs']=trim($_GPC['only_lbs']);


			$modifyData['only_lbs']=str_ireplace(',',',',$modifyData['only_lbs']);


			$modifyData['money_count']=trim($_GPC['money_count']);


			$modifyData['money_min']=trim($_GPC['money_min']);


			$modifyData['money_min']=$modifyData['money_min'] * 100;


			$modifyData['money_max']=trim($_GPC['money_max']);


			$modifyData['money_max']=$modifyData['money_max'] * 100;


			if(is_numeric($_GPC['share_money_min']))


			{


				$modifyData['share_money_min']=trim($_GPC['share_money_min']);


				$modifyData['share_money_min']=$modifyData['share_money_min'] * 100;


			}


			if(is_numeric($_GPC['share_money_max']))


			{


				$modifyData['share_money_max']=trim($_GPC['share_money_max']);


				$modifyData['share_money_max']=$modifyData['share_money_max'] * 100;


			}


			$modifyData['share_money_desc']=trim($_GPC['share_money_desc']);


			$modifyData['top_title']=trim($_GPC['top_title']);


			$modifyData['mark_info']=trim($_GPC['mark_info']);


			$modifyData['follow']=trim($_GPC['follow']);


			$modifyData['shop_name']=trim($_GPC['shop_name']);


			$modifyData['shop_lbs_value']=trim($_GPC['shop_lbs_value']);


			$modifyData['address']=trim($_GPC['address']);


			$modifyData['phone']=trim($_GPC['phone']);


			$modifyData['shop_homepage']=trim($_GPC['shop_homepage']);


			$modifyData['money_type']=trim($_GPC['money_type']);


			$modifyData['nick_name']=trim($_GPC['nick_name']);


			$modifyData['send_name']=trim($_GPC['send_name']);


			$modifyData['wishing']=trim($_GPC['wishing']);


			$modifyData['act_name']=trim($_GPC['act_name']);


			$modifyData['remark']=trim($_GPC['remark']);


			$modifyData['scene_id']=trim($_GPC['scene_id']);


			$modifyData['money_desc']=trim($_GPC['money_desc']);


			$modifyData['auto_money']=trim($_GPC['auto_money']);


			$modifyData['share_title']=trim($_GPC['share_title']);


			$modifyData['share_desc']=trim($_GPC['share_desc']);


			$modifyData['share_logo']=trim($_GPC['share_logo']);


			$modifyData['video_url']=trim($_GPC['video_url']);


			$modifyData['video_cover']=trim($_GPC['video_cover']);


			$modifyData['video_time']=trim($_GPC['video_time']);


			$modifyData['video_css']=trim($_GPC['video_css']);


			$modifyData['video_btn_name']=trim($_GPC['video_btn_name']);


			$modifyData['video_click_redirect']=trim($_GPC['video_click_redirect']);


			pdo_update('zhiwu55cn_watchvideo',$modifyData,array('id'=>$_GPC['id'],'uniacid'=>$_W['uniacid']));


			load()->func('file');


			file_write('./zhiwu55cn_watchvideo/'.$_GPC['video_filename'],$_POST['content']);


			message('修改成功!',$Zhiwu55createUrl.'&page='.$_GPC['page'],'success');






		} elseif(!empty($_GPC['modify_id'])) {


			$modifyData=pdo_get('zhiwu55cn_watchvideo',array('uniacid'=>$_W['uniacid'],'id'=>$_GPC['modify_id']));


			load()->func('file');


			$content=file_read('./zhiwu55cn_watchvideo/'.$modifyData['video_filename']);


			$start_time='';


			$end_time='';


			if(!empty($modifyData['start_time']) && $modifyData['start_time']>0 && $modifyData['start_time']!=$modifyData['end_time'])


			{


				$start_time=date('Y-m-d H:i:s',$modifyData['start_time']);


			}


			if(!empty($modifyData['end_time']) && $modifyData['end_time']>0 && $modifyData['start_time']!=$modifyData['end_time'])


			{


				$end_time=date('Y-m-d H:i:s',$modifyData['end_time']);


			}


			include $this->template("Zhiwu55create_modify");


			exit;


		} elseif(!empty($_GPC['del_id2'])) {


			pdo_delete('zhiwu55cn_watchvideo',array('id2'=>$_GPC['del_id2']));


			$qr_file=IA_ROOT.'/addons/zhiwu55cn_watchvideo/qr_file/'.$_GPC['del_id2'].'.png';;


			if(file_exists($qr_file))


			{


				@unlink($qr_file);


			}


			message('删除成功!','referer','success');


		} else {


			$total=pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('zhiwu55cn_watchvideo') . " WHERE uniacid=:uniacid",array(':uniacid'=>$_W['uniacid']));


			if(empty($total) || $_GPC['add_form']=='yes')


			{


				include $this->template("Zhiwu55create");


			} else {


				if(empty($_GPC['page']) || is_numeric($_GPC['page'])==false)


				{


					$page=1;


				} else {


					$page=$_GPC['page'];


				}


				$page=max(1,$page);


				$startNum=($page-1) * 15;


				$list=pdo_fetchall("SELECT * FROM " . tablename('zhiwu55cn_watchvideo') . "  WHERE uniacid=:uniacid ORDER BY id DESC LIMIT ".$startNum.",15",array(':uniacid'=>$_W['uniacid']));


				$pagestr=pagination($total,$page,15);


				include $this->template("Zhiwu55create_list");


			}


		}


	}


	public function doMobileZhiwu55index() // 视频首页


	{


		global $_W,$_GPC;


		$Zhiwu55indexUrl=murl('entry',array('do'=>'Zhiwu55index','m'=>$this->modulename),true,true);


		$settings=$this->module['config'];


		$count=pdo_count('zhiwu55cn_watchvideo',array('uniacid'=>$_W['uniacid']));


		if($count==0)


		{


			$msg_title='没有视频';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		if($count==1)


		{


			$id2=pdo_fetchcolumn("SELECT id2 FROM ".tablename("zhiwu55cn_watchvideo")." WHERE uniacid=".$_W['uniacid']);


			$redirectUrl=murl('entry',array('do'=>'Zhiwu55comEnter','m'=>$this->modulename,'id2'=>$id2),true,true);


			@header('Location:'.$redirectUrl);


			echo '<!DOCTYPE html>';


			echo '<html>';


			echo '<head>';


			echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';


			echo '<meta name="description" content="智伍应用专注于为国内主流的PHP开源系统研发扩展模块应用,截止2019年7月份累计的安装量已经超过百万,并且安装量每天都在增加。智伍应用一直秉承“代码全部开源并且产品免费试用,体验满意之后再考虑购买”的真诚经营理念,为海量用户提供满意的产品,面向未来,坚持自主创新,研发精品应用是我们的长远发展规划,成为最受用户信赖的技术型互联网企业是智伍应用的远景目标。">';


			echo '<meta name="keywords" content="智伍应用,www.zhiwu55.com">';


			echo '<meta name="author" content="www.zhiwu55.com">';


			echo '<meta http-equiv="Refresh" content="0;url='.$redirectUrl.'" />';


			echo '<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0,viewport-fit=cover">';


			echo '</head>';


			echo '<body>';


			echo '<script>';


			echo 'window.location.href="'.$redirectUrl.'";';


			echo '</script>';


			echo '</body>';


			echo '</html>';


			exit;


		}


		$list=pdo_fetchall("SELECT * FROM ".tablename("zhiwu55cn_watchvideo")." WHERE uniacid=".$_W['uniacid']." ORDER BY id DESC");


		$listLeft=array();


		$listRight=array();


		while($item=current($list))


		{


			$listLeft[]=$item;


			if($item=next($list))


			{


				$listRight[]=$item;


			}


			next($list);


		}


		$Zhiwu55comEnterUrl=$this->createMobileUrl("Zhiwu55comEnter");


		include $this->template("Zhiwu55index");


	}


	public function doMobileZhiwu55comEnter() // 具体某一个视频


	{


		global $_W,$_GPC;


		if(empty($_GPC['id2']))


		{


			echo 'Parameter error';


			exit;


		}


		$_GPC['id2']=trim($_GPC['id2']);


		$dataArr=pdo_get('zhiwu55cn_watchvideo',array('id2'=>$_GPC['id2']));


		if(empty($dataArr))


		{


			echo 'This video cannot be found';


			exit;


		}


		$settings=$this->module['config'];


		$Zhiwu55comEnterUrl=murl('entry',array('do'=>'Zhiwu55comEnter','m'=>$this->modulename,'id2'=>$_GPC['id2']),true,true);


		$Zhiwu55indexUrl=murl('entry',array('do'=>'Zhiwu55index','m'=>$this->modulename),true,true);


		$HzwLbsUrl=$this->createMobileUrl("HzwLbs",array('id2'=>$_GPC['id2']));


		$showErrorInfo=''; // 如果空值,表示可以领取分享红包,如果不是空值,会显示具体的原因


		if(is_numeric($dataArr['start_time']) && $dataArr['start_time']>0 && $dataArr['start_time']>TIMESTAMP)


		{


			$showErrorInfo='活动开始时间未到!';


		}


		if($showErrorInfo=='' && is_numeric($dataArr['end_time']) && $dataArr['end_time']>0 && $dataArr['end_time']<TIMESTAMP)


		{


			$showErrorInfo='活动已经结束';


		}


		if($showErrorInfo=='' && $dataArr['follow']==1 && $_W['fans']['follow']!=1)


		{


			$showErrorInfo='not_follow'; // 未关注公众号


			$uniacccount = WeAccount::create();


			$barcode['action_info']['scene']['scene_id'] = 'zhiwu55cn_watchvideo' . $_GPC['id2'];


			$barcode['action_info']['scene']['scene_str'] = 'zhiwu55cn_watchvideo' . $_GPC['id2'];


			$barcode['expire_seconds'] = 300;


			$barcode['action_name'] = 'QR_STR_SCENE';


			$result = $uniacccount->barCodeCreateDisposable($barcode);


			$qrImgUrl = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . $result['ticket'];


			echo '<!DOCTYPE html>';


			echo '<html>';


			echo '<head>';


			echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';


			echo '<meta name="description" content="智伍应用专注于为国内主流的PHP开源系统研发扩展模块应用,截止2019年7月份累计的安装量已经超过百万,并且安装量每天都在增加。智伍应用一直秉承“代码全部开源并且产品免费试用,体验满意之后再考虑购买”的真诚经营理念,为海量用户提供满意的产品,面向未来,坚持自主创新,研发精品应用是我们的长远发展规划,成为最受用户信赖的技术型互联网企业是智伍应用的远景目标。">';


			echo '<meta name="keywords" content="智伍应用,www.zhiwu55.com">';


			echo '<meta name="author" content="www.zhiwu55.com">';


			echo '<title>关注公众号</title>';


			echo '</head>';


			echo '<body>';


			echo '<img src="'.$qrImgUrl.'" style="width:100%;height:auto;" />';


			echo '</body>';


			echo '</html>';


			exit;


		}


		if(empty($_W['openid']))


		{


			$showErrorInfo='获取微信的openid出错了!';


		}


		if(empty($_GPC['ajax_video_click_redirect']))


		{


			$hzw_userInfo=$this->hzw_mc_fansinfo($_W['openid']);


			if(empty($hzw_userInfo['headimgurl']))


			{


				$hzw_userInfo=$this->hzw_mc_fansinfo($_W['openid'],true);


			}


		}


		if($showErrorInfo=='')


		{


			$checkUser=pdo_get("zhiwu55cn_watchvideo_money",array("openid"=>$_W["openid"],"set_id"=>$dataArr['id'],"uniacid"=>$_W["uniacid"]));


			if(empty($checkUser))


			{


				if(is_numeric($dataArr['money_count_use']) && is_numeric($dataArr['money_count']) && $dataArr['money_count_use']>0 && $dataArr['money_count']>0 && $dataArr['money_count_use']>=$dataArr['money_count'])


				{


					$showErrorInfo='你来晚了!红包已经发完了!';






				} else {






					if(!empty($_GPC['share_openid']) && $_GPC['share_openid']!=$_W['openid']) // 记录转发分享的推广者的openid


					{


						$share_openid=$_GPC['share_openid'];


						isetcookie('share_openid',$share_openid,600);


					} else {


						$share_openid='';


					}


					pdo_insert("zhiwu55cn_watchvideo_money",array("openid"=>$_W["openid"],'share_openid'=>$share_openid,"set_id"=>$dataArr['id'],"uniacid"=>$_W["uniacid"],"nickname"=>$hzw_userInfo["nickname"],'ip'=>CLIENT_IP,'dateline'=>time()));


					$money_count_use=pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE set_id=".$dataArr['id']." AND uniacid=".$_W["uniacid"]);


					pdo_update("zhiwu55cn_watchvideo",array("money_count_use"=>$money_count_use),array("id"=>$dataArr['id']));






				}






			} elseif($checkUser['return_msg']=='SUCCESS') {






				$showErrorInfo='你已经领取微信红包!不能重复领取!';






			}






		}


		if($showErrorInfo=='' && !empty($dataArr['only_lbs']) && empty($checkUser['lbs_detail']))


		{


			$showErrorInfo='Authorize_access_to_geographic_locations';


		}


		$areaPass=false; // 限制区域领取红包,如果为true,表示通过区域检测


		if($showErrorInfo=='' && empty($dataArr['only_lbs']))


		{


			$areaPass=true;


		}


		if($showErrorInfo=='' && !$areaPass && !empty($checkUser['lbs_detail']))


		{


			$dataArr['only_lbs']=trim($dataArr['only_lbs']);


			$lbs_area_arr=explode(',',$dataArr['only_lbs']);


			if(!empty($lbs_area_arr) && is_array($lbs_area_arr) && count($lbs_area_arr)>0)


			{


				foreach($lbs_area_arr as $localItem)


				{


					if(strlen($localItem)>1 && mb_strpos($checkUser['lbs_detail'],$localItem,0,"UTF-8")!==false)


					{


						$areaPass = true;


						break;


					}


				}






			} else {






				if(mb_strpos($checkUser['lbs_detail'],$dataArr['only_lbs'],0,"UTF-8")!==false)


				{


					$areaPass = true;


				}


			}






		}


		if($showErrorInfo=='' && !$areaPass)


		{


			$showErrorInfo='该活动限制了区域,你不符合要求!';


		}


		$hzw_default_template=''; // 领取红包按钮


		$hzw_default_template=$hzw_default_template.'<section style="margin: 10px auto;text-align: center;">';


		$hzw_default_template=$hzw_default_template.'	<section style="padding-top: 3px;">';


		$hzw_default_template=$hzw_default_template.'		<section style="display: inline-block;">';


		$hzw_default_template=$hzw_default_template.'			<section style="box-sizing: border-box;display: flex;">';


		$hzw_default_template=$hzw_default_template.'				<section style="color: #b25d0a;text-decoration: none;font-size: 16px;color:#ffffff;letter-spacing: 1.5px;padding:10px 60px 10px 15px;word-break: break-all;border-radius: 30px;background-image: linear-gradient(to right,#ffaa77,#fb5856);">';


		$hzw_default_template=$hzw_default_template.'					<strong><a href="#" id="video_btn_name" style="color:#FFF">'.$dataArr['video_btn_name'].'</a></strong>';


		$hzw_default_template=$hzw_default_template.'				</section>';


		$hzw_default_template=$hzw_default_template.'				<section style="display: flex;justify-content: flex-end;align-items: center;margin-left: -45px;margin-right: 10px;user-select: none;pointer-events: none;">';


		$hzw_default_template=$hzw_default_template.'					<section style="box-sizing:border-box;display: inline-block;width: 35px;height: 35px;transform: rotate(0deg);line-height: 35px;font-size: 12px;color: #b25d0a;letter-spacing: 1.5px;background-image: linear-gradient(#ffe684,#f8ae43);text-align: center;word-break: break-all;border-radius: 100%;box-shadow: 0 0 10px #e43633;">';


		$hzw_default_template=$hzw_default_template.'						<strong>GO</strong>';


		$hzw_default_template=$hzw_default_template.'					</section>';


		$hzw_default_template=$hzw_default_template.'				</section>';


		$hzw_default_template=$hzw_default_template.'			</section>';


		$hzw_default_template=$hzw_default_template.'		</section>';


		$hzw_default_template=$hzw_default_template.'	</section>';


		$hzw_default_template=$hzw_default_template.'</section>';


		$hzw_video_template='<video controls src="'.tomedia($dataArr['video_url']).'" style="'.$dataArr['video_css'].'" poster="'.tomedia($dataArr['video_cover']).'" preload="auto" id="zhiwu55Video"></video>'; // 播放视频HTML代码


		load()->func('file');


		$content=file_read('./zhiwu55cn_watchvideo/'.$dataArr['video_filename']);


		$content=str_ireplace('_hzw_receive_money_button_',$hzw_default_template,$content);


		$content=str_ireplace('_hzw_video_tag_',$hzw_video_template,$content);


		$shop_lbs_value_arr=explode(',',$dataArr['shop_lbs_value']);


		$share_logo=tomedia($dataArr['share_logo']);


		if($_GPC['ajax_video_click_redirect']=='yes') // 前端ajax请求,返回跳转链接地址,并领取红包


		{


			if($showErrorInfo!='')


			{


				echo $showErrorInfo;


				exit;


			}


			$now_time=time();


			$sign=$now_time.$_W['account']['secret'].$_W['openid'];


			$sign=md5($sign);


			$Zhiwu55comRedirectUrl=$this->createMobileUrl("Zhiwu55comRedirectUrl",array('now_time'=>$now_time,'sign'=>$sign,'id2'=>$_GPC['id2']));


			echo $Zhiwu55comRedirectUrl;


			exit;


		}


		$videoCount=pdo_count('zhiwu55cn_watchvideo',array('uniacid'=>$_W['uniacid']));


		include $this->template("Zhiwu55comEnter");


	}


	public function doMobileZhiwu55comRedirectUrl() // 跳转链接,并发放红包


	{


		global $_W,$_GPC;


		if(empty($_GPC['now_time']) || empty($_GPC['sign']) || empty($_GPC['id2']) || !is_numeric($_GPC['now_time']))


		{


			$msg_title='参数出错了';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		$sign=$_GPC['now_time'].$_W['account']['secret'].$_W['openid'];


		$sign=md5($sign);


		if($sign!=$_GPC['sign'])


		{


			$msg_title='签名出错了';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		$dataArr=pdo_get('zhiwu55cn_watchvideo',array('id2'=>$_GPC['id2']));


		if(empty($dataArr))


		{


			$msg_title='视频已经被删除';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		$diffTime=time();


		$diffTime=$diffTime-$_GPC['now_time'];


		if($diffTime<($dataArr['video_time']-2))


		{


			$msg_title='请正常看完视频';


			$msg_desc='点击播放之后,不要快进,不要长时间暂停,正常看完全程视频!';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		if($diffTime>($dataArr['video_time'] * 5))


		{


			$msg_title='闲置太久';


			$msg_desc='点击播放之后,不要长时间暂停,正常看完全程视频!';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		if(is_numeric($dataArr['money_count_use']) && is_numeric($dataArr['money_count']) && $dataArr['money_count_use']>0 && $dataArr['money_count']>0 && $dataArr['money_count_use']>=$dataArr['money_count'])


		{


			$msg_title='你来晚了';


			$msg_desc='红包已经全部发完了!请留意下一波红包!';


			$btn1_name='继续浏览跳转链接';


			$btn1_href=$dataArr['video_url'];


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		if(is_numeric($dataArr['start_time']) && $dataArr['start_time']>0 && $dataArr['start_time']>TIMESTAMP)


		{


			$msg_title='活动开始时间未到!';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		if(is_numeric($dataArr['end_time']) && $dataArr['end_time']>0 && $dataArr['end_time']<TIMESTAMP)


		{


			$msg_title='活动已经结束';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		if($dataArr['follow']==1 && $_W['fans']['follow']!=1)


		{


			$msg_title='未关注公众号';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		if(empty($_W['openid']))


		{


			$msg_title='获取openid失败';


			$msg_desc='';


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		$checkUser=pdo_get("zhiwu55cn_watchvideo_money",array("openid"=>$_W["openid"],"set_id"=>$dataArr['id'],"uniacid"=>$_W["uniacid"]));


		if($checkUser['return_msg']=='SUCCESS')


		{


			$msg_title='你已经领取微信红包';


			$msg_desc='请返回微信首页查收你的红包,请不要重复领取!';


			$btn1_name='继续浏览跳转链接';


			$btn1_href=$dataArr['video_url'];


			include $this->template("zhiwu55cnMessage");


			exit;


		}


		$dataArr['money']=rand($dataArr['money_min'],$dataArr['money_max']);


		if($dataArr['auto_money']==1)


		{


			$dataArr['openid']=$_W["openid"];


			if(!empty($checkUser["share_openid"]) && empty($checkUser["share_openid_return_msg"]) && !empty($dataArr['share_money_min']) && !empty($dataArr['share_money_max']) && !empty($dataArr['share_money_desc']))


			{


				$dataArr['share_openid_money']=rand($dataArr['share_money_min'],$dataArr['share_money_max']);


				$dataArr['share_money_desc']=$dataArr['share_money_desc'];


				$dataArr['share_openid']=$checkUser["share_openid"];


				$checkSql=pdo_update("zhiwu55cn_watchvideo_money",array("money"=>$dataArr['money'],"return_msg"=>"SUCCESS","return_msg_dateline"=>time(),"share_openid_money"=>$dataArr['share_openid_money'],"share_openid_return_msg"=>"SUCCESS","share_openid_dateline"=>time()),array("id"=>$checkUser["id"]));






			} else {






				$checkSql=pdo_update("zhiwu55cn_watchvideo_money",array("money"=>$dataArr['money'],"return_msg"=>"SUCCESS","return_msg_dateline"=>time()),array("id"=>$checkUser["id"]));


			}


			if(empty($checkSql))


			{


				$msg_title='数据库出错';


				$msg_desc='请联系技术人员反馈问题';


				include $this->template("zhiwu55cnMessage");


				exit;






			} else {






				$dataArr['return_msg']=$checkUser['return_msg'];


				$dataArr['lbs_md5_hash']=$checkUser['lbs_md5_hash'];


				$dataArr['ip']=$checkUser['ip'];


				$resultArr=$this->send_money($dataArr);


				if(is_array($resultArr))


				{


					if($resultArr['return_msg']!='SUCCESS' || ($resultArr['share_return_msg']!='SUCCESS' && $resultArr['share_return_msg']!='hzw_no'))


					{


						pdo_update("zhiwu55cn_watchvideo_money",array("return_msg"=>$resultArr['return_msg'],"share_openid_return_msg"=>$resultArr['share_return_msg']),array("id"=>$checkUser["id"]));


					}


				}






			}






		} else {






			pdo_update("zhiwu55cn_watchvideo_money",array("money"=>$dataArr['money'],"return_msg"=>"pending","return_msg_dateline"=>time()),array("id"=>$checkUser["id"]));






		}


		echo '<!DOCTYPE html>';


		echo '<html>';


		echo '<head>';


		echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';


		echo '<meta name="description" content="智伍应用专注于为国内主流的PHP开源系统研发扩展模块应用,截止2019年7月份累计的安装量已经超过百万,并且安装量每天都在增加。智伍应用一直秉承“代码全部开源并且产品免费试用,体验满意之后再考虑购买”的真诚经营理念,为海量用户提供满意的产品,面向未来,坚持自主创新,研发精品应用是我们的长远发展规划,成为最受用户信赖的技术型互联网企业是智伍应用的远景目标。">';


		echo '<meta name="keywords" content="智伍应用,www.zhiwu55.com">';


		echo '<meta name="author" content="www.zhiwu55.com">';


		echo '<meta http-equiv="Refresh" content="0;url='.$dataArr['video_click_redirect'].'" />';


		echo '</head>';


		echo '<body>';


		echo '<a href="'.$dataArr['video_click_redirect'].'">如果不会跳转,请点击这儿!</a>';


		echo '<script>';


		echo 'window.location.href="'.$dataArr['video_click_redirect'].'";';


		echo '</script>';


		echo '</body>';


		echo '</html>';






	}


	private function send_money($dataArr) // 发放红包


	{


		global $_W,$_GPC;


		if($dataArr['return_msg']=='SUCCESS')


		{


			return '红包已经发放!';


		}


		$settings=$this->module['config'];


		if($settings['only_one']==2)


		{


			if(empty($_GPC['hzw_lock']))


			{


				isetcookie('hzw_lock','open',1);


			} else {


				return array('return_msg'=>'禁止频繁领取红包!','share_return_msg'=>'');


			}


			$only_one_hint=empty($settings['only_one_hint'])?'太多人抢红包了,有点拥挤,刚才的那个红包被别人先抢走了,红包还有,排队领取,请继续参于抢红包!':$settings['only_one_hint'];


			$zhiwu_cache_name='zhiwu55cn_watchvideo_only_one'.$_W['uniacid'];


			$zhiwu55_only_one=cache_load($zhiwu_cache_name);


			$nowTime=time();


			if(empty($zhiwu55_only_one))


			{


				cache_write($zhiwu_cache_name,$nowTime);


			} else {


				$zhiwu55_only_one=intval($zhiwu55_only_one);


				if($nowTime==$zhiwu55_only_one)


				{


					return array('return_msg'=>$only_one_hint,'share_return_msg'=>'');


				} else {


					cache_write($zhiwu_cache_name,$nowTime);


				}


			}


		}


		if($settings['max_ip_get']==2 && is_numeric($settings['max_ip_get_num']) && $settings['max_ip_get_num']>0)


		{


			$ThisIpCount=pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE return_msg='SUCCESS' AND ip ='".$dataArr['ip']."' AND uniacid=".$_W['uniacid']);


			if($ThisIpCount>$settings['max_ip_get_num'])


			{


				return array('return_msg'=>'IP:'.$dataArr['ip'].',领取红包超过'.$settings['max_ip_get_num'].'个,需要人工二次审核发放!','share_return_msg'=>'');


			}


		}


		if(!empty($dataArr['only_lbs']) && $settings['max_lbs_get']==2 && is_numeric($settings['max_lbs_get_num']) && $settings['max_lbs_get_num']>0 && !empty($dataArr['lbs_md5_hash']))


		{


			$ThisLbsCount=pdo_fetchcolumn("SELECT COUNT(*) FROM ".tablename("zhiwu55cn_watchvideo_money")." WHERE return_msg='SUCCESS' AND lbs_md5_hash='".$dataArr['lbs_md5_hash']."' AND uniacid=".$_W['uniacid']);


			if($ThisLbsCount>$settings['max_lbs_get_num'])


			{


				return array('return_msg'=>'该LBS地理位置领取红包超过'.$settings['max_lbs_get_num'].'个,需要人工二次审核发放!','share_return_msg'=>'');


			}


		}


		if($dataArr['money_type']==2)


		{


			$url                   = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack';


			$pars                  = array();


			$pars['nonce_str']     = random(32);


			$pars['mch_billno']    = $settings['hzwMch_id'] . date('Ymd',time()) . substr(md5(uniqid()),0,10);


			$pars['mch_id']        = $settings['hzwMch_id'];


			$pars['wxappid']       = $_W['account']['key'];


			$pars['nick_name']     = $dataArr['nick_name'];


			$pars['send_name']     = $dataArr['send_name'];


			$pars['re_openid']     = $dataArr['openid'];


			$pars['total_amount']  = $dataArr['money'];


			$pars['min_value']     = $dataArr['money'];


			$pars['max_value']     = $dataArr['money'];


			$pars['total_num']     = 1;


			$pars['wishing']       = $dataArr['wishing'];


			$pars['client_ip']     = $settings['hzwClient_ip'];


			$pars['act_name']      = $dataArr['act_name'];


			$pars['remark']        = $dataArr['remark'];


			if($dataArr['money']<100 || $dataArr['money']>20000)


			{


				$pars['scene_id']  = $dataArr['scene_id'];


			}


			ksort($pars, SORT_STRING);


			$string1 = '';


			foreach ($pars as $k => $v) {


				$string1 .= "{$k}={$v}&";


			}


			$string1 .= "key=" . $settings['hzwApiKey'];


			$pars['sign'] = strtoupper(md5($string1));


			$xml = array2xml($pars);


			$extras = array();


			$extras['CURLOPT_SSLCERT'] = $settings['hzwApiclient_cert'];


			$extras['CURLOPT_SSLKEY']  = $settings['hzwApiclient_key'];


			load()->func('communication');


			$procResult = null;


			$resp = ihttp_request($url, $xml, $extras);


			if (is_error($resp)) {


				$return_msg="不能发起http请求!";


			} else {


				$xml = '<?xml version="1.0" encoding="utf-8"?>' . $resp['content'];


				$dom = new DOMDocument();


				if ($dom->loadXML($xml)) {


					$xpath = new DOMXPath($dom);


					$code  = $xpath->evaluate('string(//xml/return_code)');


					$return_msg  = $xpath->evaluate('string(//xml/return_msg)');


					$ret   = $xpath->evaluate('string(//xml/result_code)');


					if (strtolower($code) == 'success' && strtolower($ret) == 'success') {


						$return_msg = 'SUCCESS';


					} else {


						$return_msg = $xpath->evaluate('string(//xml/err_code_des)');


					}


				} else {


					$return_msg = "loadXML出错!!";


				}


			}






		} else {






			$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';


			$pars = array();


			$pars['mch_appid'] = $_W['account']['key'];


			$pars['mchid'] = $settings['hzwMch_id'];


			$pars['nonce_str'] = random(32);


			$pars['partner_trade_no'] = $settings['hzwMch_id'] . date('Ymd',time()) . substr(md5(uniqid()),0,10);


			$pars['openid'] = $dataArr['openid'];


			$pars['check_name'] = "NO_CHECK";


			$pars['amount'] = $dataArr['money'];


			$pars['desc'] = $dataArr['money_desc'];


			$pars['spbill_create_ip'] = $settings['hzwClient_ip'];


			ksort($pars, SORT_STRING);


			$string1 = '';


			foreach ($pars as $k => $v) {


				$string1 .= "{$k}={$v}&";


			}


			$string1 .= "key={$settings['hzwApiKey']}";


			$pars['sign'] = strtoupper(md5($string1));


			$xml = array2xml($pars);


			$extras = array();


			$extras['CURLOPT_SSLCERT'] = $settings['hzwApiclient_cert'];


			$extras['CURLOPT_SSLKEY'] = $settings['hzwApiclient_key'];


			load()->func('communication');


			$resp = ihttp_request($url, $xml, $extras);


			if (is_error($resp)) {


				$return_msg = $resp['message'];


			} else {


				$xml = '<?xml version="1.0" encoding="utf-8"?>' . $resp['content'];


				$dom = new DOMDocument();


				if ($dom->loadXML($xml)) {


					$xpath = new DOMXPath($dom);


					$code = $xpath->evaluate('string(//xml/return_code)');


					$result = $xpath->evaluate('string(//xml/result_code)');


					if (strtolower($code) == 'success' && strtolower($result) == 'success') {


						$return_msg = 'SUCCESS';


					} else {


						$return_msg = $xpath->evaluate('string(//xml/err_code_des)');


					}


				} else {


					$return_msg = 'loadXML出错!!';


				}


			}


		}


		if(!empty($dataArr['share_openid'])) // 分享转发推广者奖励红包


		{






			$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';


			$pars = array();


			$pars['mch_appid'] = $_W['account']['key'];


			$pars['mchid'] = $settings['hzwMch_id'];


			$pars['nonce_str'] = random(32);


			$pars['partner_trade_no'] = $settings['hzwMch_id'] . date('Ymd',time()) . substr(md5(uniqid()),0,10);


			$pars['openid'] = $dataArr['share_openid'];


			$pars['check_name'] = "NO_CHECK";


			$pars['amount'] = $dataArr['share_openid_money'];


			$pars['desc'] = $dataArr['share_money_desc'];


			$pars['spbill_create_ip'] = $settings['hzwClient_ip'];


			ksort($pars, SORT_STRING);


			$string1 = '';


			foreach ($pars as $k => $v) {


				$string1 .= "{$k}={$v}&";


			}


			$string1 .= "key={$settings['hzwApiKey']}";


			$pars['sign'] = strtoupper(md5($string1));


			$xml = array2xml($pars);


			$extras = array();


			$extras['CURLOPT_SSLCERT'] = $settings['hzwApiclient_cert'];


			$extras['CURLOPT_SSLKEY'] = $settings['hzwApiclient_key'];


			load()->func('communication');


			$resp = ihttp_request($url, $xml, $extras);


			if (is_error($resp)) {


				$share_return_msg = $resp['message'];


			} else {


				$xml = '<?xml version="1.0" encoding="utf-8"?>' . $resp['content'];


				$dom = new DOMDocument();


				if ($dom->loadXML($xml)) {


					$xpath = new DOMXPath($dom);


					$code = $xpath->evaluate('string(//xml/return_code)');


					$result = $xpath->evaluate('string(//xml/result_code)');


					if (strtolower($code) == 'success' && strtolower($result) == 'success') {


						$share_return_msg = 'SUCCESS';


					} else {


						$share_return_msg = $xpath->evaluate('string(//xml/err_code_des)');


					}


				} else {


					$share_return_msg = 'loadXML出错!!';


				}


			}






		} else {






			$share_return_msg='hzw_no';






		}


		return array('return_msg'=>$return_msg,'share_return_msg'=>$share_return_msg);


	}


	private function send_share_money($dataArr) // 发放推广奖励红包


	{


		global $_W,$_GPC;


		if(empty($_GPC['hzw_lock']))


		{


			isetcookie('hzw_lock','open',1);


		} else {


			return '禁止频繁领取红包!';


		}


		if($dataArr['share_openid_return_msg']=='SUCCESS')


		{


			return '红包已经发放!';


		}


		$settings=$this->module['config'];


		if(!empty($dataArr['share_openid'])) // 分享转发推广者奖励红包


		{






			$url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';


			$pars = array();


			$pars['mch_appid'] = $_W['account']['key'];


			$pars['mchid'] = $settings['hzwMch_id'];


			$pars['nonce_str'] = random(32);


			$pars['partner_trade_no'] = $settings['hzwMch_id'] . date('Ymd',time()) . substr(md5(uniqid()),0,10);


			$pars['openid'] = $dataArr['share_openid'];


			$pars['check_name'] = "NO_CHECK";


			$pars['amount'] = $dataArr['share_openid_money'];


			$pars['desc'] = $dataArr['share_money_desc'];


			$pars['spbill_create_ip'] = $settings['hzwClient_ip'];


			ksort($pars, SORT_STRING);


			$string1 = '';


			foreach ($pars as $k => $v) {


				$string1 .= "{$k}={$v}&";


			}


			$string1 .= "key={$settings['hzwApiKey']}";


			$pars['sign'] = strtoupper(md5($string1));


			$xml = array2xml($pars);


			$extras = array();


			$extras['CURLOPT_SSLCERT'] = $settings['hzwApiclient_cert'];


			$extras['CURLOPT_SSLKEY'] = $settings['hzwApiclient_key'];


			load()->func('communication');


			$resp = ihttp_request($url, $xml, $extras);


			if (is_error($resp)) {


				$share_return_msg = $resp['message'];


			} else {


				$xml = '<?xml version="1.0" encoding="utf-8"?>' . $resp['content'];


				$dom = new DOMDocument();


				if ($dom->loadXML($xml)) {


					$xpath = new DOMXPath($dom);


					$code = $xpath->evaluate('string(//xml/return_code)');


					$result = $xpath->evaluate('string(//xml/result_code)');


					if (strtolower($code) == 'success' && strtolower($result) == 'success') {


						$share_return_msg = 'SUCCESS';


					} else {


						$share_return_msg = $xpath->evaluate('string(//xml/err_code_des)');


					}


				} else {


					$share_return_msg = 'loadXML出错!!';


				}


			}






		} else {






			$share_return_msg='hzw_no';






		}


		return $share_return_msg;


	}


	private function format_time($time) {


        // $time = strtotime($time);


        if (empty($time)) {


            return '';


        }


        if (!is_numeric($time)) {


            if (PHP_VERSION < 5) {


                $matchs = array();


                preg_match_all('/(\S+)/', $time, $matchs);


                if ($matchs[0]) {


                    $Mtom = array('Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12');


                    $time = $matchs[0][5] . $Mtom[$matchs[0][1]] . $matchs[0][2] . ' ' . $matchs[0][3];


                }


            }


            $t = strtotime($time);


        } else {


            $t = $time;


        }


        $differ = time() - $t;


        $year = date('Y', time());


        if (($year % 4) == 0 && ($year % 100) > 0) {


            //闰年


            $days = 366;


        } elseif (($year % 100) == 0 && ($year % 400) == 0) {


            //闰年


            $days = 366;


        } else {


            $days = 365;


        }


        if ($differ <= 60) {


            //小于1分钟


            if ($differ <= 0) {


                $differ = 1;


            }


            $format_time = sprintf('%d秒前', $differ);


        } elseif ($differ > 60 && $differ <= 60 * 60) {


            //大于1分钟小于1小时


            $min = floor($differ / 60);


            $format_time = sprintf('%d分钟前', $min);


        } elseif ($differ > 60 * 60 && $differ <= 60 * 60 * 24) {


			$beforHour = $differ / 3600;


			$beforHour = intval($beforHour);


			$format_time =sprintf('%d小时前',$beforHour);


        } elseif ($differ > 60 * 60 * 24 && $differ <= 60 * 60 * 24 * 30) {


			$beforDays = $differ / 86400;


			$format_time =sprintf('%d天前',$beforDays);


        } elseif ($differ > 60 * 60 * 24 * 30 && $differ <= 60 * 60 * 24 * $days) {


            $beformonth = $differ / 2592000;


			$format_time =sprintf('%d月前',$beformonth);


        } else {


            //大于今年


            $format_time = sprintf('%d-%d-%d', date('Y', $t), date('n', $t), date('d', $t));


        }


        return $format_time;


    }


}
回答关注问题邀请回答
收藏

1 个回答

  • 徐
    2022-10-07

    请联系我

    2022-10-07
    有用
    回复
登录 后发表内容