|
|
<?php
|
|
|
namespace app\products\controller;
|
|
|
|
|
|
|
|
|
use app\serviceapi\controller\TurnPrize as TurnPrizeModel;
|
|
|
use app\web\controller\BaseController;
|
|
|
use think\Log;
|
|
|
use think\Request;
|
|
|
use util\MCurl;
|
|
|
use think\Cookie;
|
|
|
use think\Session;
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
|
header('Access-Control-Allow-Origin:*');
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
|
|
|
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
|
|
|
/**
|
|
|
* 功能描述 抽奖管理
|
|
|
* Class TurnTable
|
|
|
* @package app\products\controller
|
|
|
* Date: 2020/8/25
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
class TurnPrize extends BaseController
|
|
|
{
|
|
|
private $appid = 'wx3e41adc018004fd1';
|
|
|
private $appsecrt = 'f072ba0a6dbb24a2f6b504259367ecfc';
|
|
|
|
|
|
//请求地址
|
|
|
//private $api_url = "http://demo8.xiaochakeji.com/serviceapi/prize/";
|
|
|
//查询接口
|
|
|
//本地
|
|
|
//private $api_url = "www.aisigit.com/products/Turn_prize/";
|
|
|
//测试
|
|
|
//private $api_url = "http://demo6.xiaochakeji.com/products/Turn_prize/";
|
|
|
//生产
|
|
|
// private $api_url = "http://hzy.sosyun.com/products/Turn_prize/";
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 微信分享获取AccessToken
|
|
|
* Date: 2020/8/31
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function getAccessToken() {
|
|
|
//查询数据表里面的值
|
|
|
$data['appid']= $this->appid;
|
|
|
$data['appsecrt']= $this->appsecrt;
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$info = $prize_win_model->getAccessToken();
|
|
|
//$info = MCurl::instance($this->api_url."getAccessToken")->post($data);
|
|
|
$info = json_decode($info,true);
|
|
|
|
|
|
if(empty($info) || $info['expires_in'] < time()){
|
|
|
//获取token的值
|
|
|
$url_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->appid . "&secret=" . $this->appsecrt;
|
|
|
$tmp = $this->curl_get($url_token); //json格式
|
|
|
$obj = json_decode($tmp,true);
|
|
|
if($obj['access_token'] != null){
|
|
|
$data['access_token'] = $obj['access_token'];
|
|
|
$data['expires_in'] = time() + $obj['expires_in'];
|
|
|
|
|
|
if($info){
|
|
|
$data['id'] = $info['id'];
|
|
|
$arr = $prize_win_model->updateAccessToken($data);
|
|
|
//$arr = MCurl::instance($this->api_url."updateAccessToken")->post($data);
|
|
|
}else{
|
|
|
$arr = $prize_win_model->addAccessToken($data);
|
|
|
// $arr = MCurl::instance($this->api_url."addAccessToken")->post($data);
|
|
|
|
|
|
}
|
|
|
return $data;
|
|
|
}else return 'error';
|
|
|
}else return $info;
|
|
|
}
|
|
|
/**
|
|
|
* 函数功能描述 微信分享获取Ticket
|
|
|
* Date: 2020/8/31
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function getTicket(){
|
|
|
$token = $this->getAccessToken();
|
|
|
|
|
|
if(empty($token['jsapi_ticket']) || $token['expires_in'] < time()){
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$token['access_token']."&type=jsapi";
|
|
|
$tmp = $this->curl_get($url); //json格式
|
|
|
$obj = json_decode($tmp,true);
|
|
|
|
|
|
$data['id'] = $token['id'];
|
|
|
$data['jsapi_ticket'] = $obj['jsapi_ticket'];
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$arr = $prize_win_model->updateAccessToken($data);
|
|
|
//$arr = MCurl::instance($this->api_url."updateAccessToken")->post($data);
|
|
|
return $obj['jsapi_ticket'];
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return $token['jsapi_ticket'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 微信分享获取sdk
|
|
|
* Date: 2020/8/31
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function generateSign(Request $request){
|
|
|
$dataurl = $request->param('url');
|
|
|
//echo $dataurl;die;
|
|
|
$url=str_replace('amp;','',$dataurl);
|
|
|
$noncestr = uniqid();
|
|
|
$timestamp = time();
|
|
|
//$url = 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
|
|
$ticket = $this->getTicket();
|
|
|
|
|
|
if ($ticket) {
|
|
|
$str = 'jsapi_ticket='.$ticket.'&noncestr='.$noncestr.'×tamp='.$timestamp.'&url='.$url;
|
|
|
//return $str;die;
|
|
|
$signature = sha1($str);
|
|
|
|
|
|
$data['ticket'] = $ticket;
|
|
|
$data['noncestr'] = $noncestr;
|
|
|
$data['timestamp'] = $timestamp;
|
|
|
$data['signature'] = $signature;
|
|
|
$data['appId'] = $this->appid;
|
|
|
$data['link'] = $url;
|
|
|
return $data;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 抽奖用户模拟微信授权 返回 openid
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
|
|
|
public function getWxCode(Request $request)
|
|
|
{
|
|
|
$data = $request->param();
|
|
|
$code=$data['code'];
|
|
|
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $this->appid . "&secret=" . $this->appsecrt . "&code=$code&grant_type=authorization_code";
|
|
|
$r = $this->curl_get($url);
|
|
|
$openid=json_decode($r,true);
|
|
|
return $openid;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 获取订单信息 / 获取奖品列表接口
|
|
|
* Date: 2020/8/27
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function prize_list(Request $request)
|
|
|
{
|
|
|
$data = $request->param();
|
|
|
//分页暂未开启,保留.
|
|
|
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
|
|
|
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 25;
|
|
|
$offset=($page-1)*$rows;
|
|
|
$data['offset']=$offset;
|
|
|
$data['rows']=$rows;
|
|
|
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeList($data);
|
|
|
|
|
|
//$res = MCurl::instance($this->api_url."prizeList")->post($data);
|
|
|
|
|
|
$json=json_decode($res,true);
|
|
|
|
|
|
foreach($json as $key=>$val ){
|
|
|
$json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']);
|
|
|
if($val['display'] ==0){
|
|
|
$json[$key]['display']="已发布";
|
|
|
}else{
|
|
|
$json[$key]['display']="未发布";
|
|
|
}
|
|
|
}
|
|
|
$result["total"] =count($json);
|
|
|
$result['rows']=$json;
|
|
|
echo json_encode($result);
|
|
|
//return $json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 文件上传
|
|
|
* Date: 2020/8/07
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function uploadFileImgs(){
|
|
|
$files = request()->file('files');
|
|
|
$path = input('path');
|
|
|
if($files){
|
|
|
$imgarr = [];
|
|
|
foreach($files as $file){
|
|
|
$info = $file->validate(['size'=>204800000,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public/web/' . DS . 'prize');
|
|
|
if($info){
|
|
|
$newurl = '/web/prize/'.$info->getSaveName();
|
|
|
$img= str_replace('\\','/',$newurl);
|
|
|
|
|
|
$imgarr[]=$img;
|
|
|
}
|
|
|
}
|
|
|
return json_encode($imgarr);
|
|
|
}else{
|
|
|
echo '没有图片上传';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 删除中奖用户列表
|
|
|
* Date: 2020/8/07
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function del_user()
|
|
|
{
|
|
|
$data = $this->request->post();
|
|
|
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->delUser($data);
|
|
|
//$res = MCurl::instance($this->api_url."delUser")->post($data);
|
|
|
|
|
|
$json=json_decode($res,true);
|
|
|
if(is_numeric($json)){
|
|
|
$data=[
|
|
|
'code'=>200,
|
|
|
'msg'=>'删除成功'
|
|
|
];
|
|
|
}else{
|
|
|
$data=[
|
|
|
'code'=>100,
|
|
|
'msg'=>'删除失败'
|
|
|
];
|
|
|
}
|
|
|
return $data;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 添加奖品
|
|
|
* Date: 2020/8/07
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function prize_add(Request $request)
|
|
|
{
|
|
|
$data = $request->param();
|
|
|
$data['addTime']=time();
|
|
|
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeAdd($data);
|
|
|
//return $res;
|
|
|
|
|
|
// $res = MCurl::instance($this->api_url."prizeAdd")->post($data);
|
|
|
$json=json_decode($res,true);
|
|
|
if(is_numeric($json)){
|
|
|
$data=[
|
|
|
'code'=>200,
|
|
|
'msg'=>'修改成功'
|
|
|
];
|
|
|
}else{
|
|
|
$data=[
|
|
|
'code'=>100,
|
|
|
'msg'=>'修改失败'
|
|
|
];
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 中奖用户列表
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function prize_user_list(Request $request)
|
|
|
{
|
|
|
$data = $request->param();
|
|
|
|
|
|
$page = $data['page'];
|
|
|
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
|
|
|
$offset=($page-1)*$rows;
|
|
|
$data['offset']=$offset;
|
|
|
$data['rows']=$rows;
|
|
|
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeUserList($data);
|
|
|
//var_dump($res); die;
|
|
|
//$res = MCurl::instance($this->api_url."prizeUserList")->post($data);
|
|
|
|
|
|
//$res=json_decode($res,true);
|
|
|
$json=$res['rows'];
|
|
|
unset($data['id']);
|
|
|
Cookie::set('data', $data);
|
|
|
foreach($json as $key=>$val ){
|
|
|
$json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']);
|
|
|
if(isset($val['num']) && $val['num'] !=1 ){
|
|
|
$json[$key]['prizeName']="双击查看";
|
|
|
}
|
|
|
|
|
|
if($val['receive'] ==0){
|
|
|
$json[$key]['receive']="未领取";
|
|
|
}else{
|
|
|
$json[$key]['receive']="已领取";
|
|
|
}
|
|
|
}
|
|
|
$last_names = array_column($json,'addTime');
|
|
|
array_multisort($last_names,SORT_DESC,$json);
|
|
|
|
|
|
//获取当前的条数
|
|
|
// if(isset($data['phone'])&&!empty($data['phone'])) {
|
|
|
// $count = count($json);
|
|
|
// }else{
|
|
|
// $count = MCurl::instance($this->api_url . "prizeUserCount")->post($data);
|
|
|
// $count = json_decode($count, true);
|
|
|
// }
|
|
|
$result["total"] =$res['total'];
|
|
|
$result['rows']=$json;
|
|
|
echo json_encode($result);
|
|
|
//return $json;
|
|
|
}
|
|
|
/**
|
|
|
* 函数功能描述 导出数据到表格
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function to_excel()
|
|
|
{
|
|
|
$data = $this->request->Post();
|
|
|
$data= Cookie::get('data');
|
|
|
$data['to_excel']=1;
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$json = $prize_win_model->prizeUserList($data);
|
|
|
//$res = MCurl::instance($this->api_url."prizeUserList")->post($data);
|
|
|
|
|
|
// $json=json_decode($res,true);
|
|
|
foreach($json as $key=>$val ){
|
|
|
$json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']);
|
|
|
}
|
|
|
ob_end_clean();//清除缓冲区,避免乱码
|
|
|
Vendor('PHPExcel.PHPExcel');
|
|
|
$objPHPExcel=new \PHPExcel();
|
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
|
->setCellValue('A1', '用户名')
|
|
|
->setCellValue('B1', '电话')
|
|
|
->setCellValue('C1', '奖品名称')
|
|
|
->setCellValue('D1', '部门')
|
|
|
->setCellValue('E1', '时间');
|
|
|
$rowIndex = 2;
|
|
|
|
|
|
foreach ($json as $k => $v) {
|
|
|
$objPHPExcel->getActiveSheet()
|
|
|
->setCellValue('A' . $rowIndex, $v['uname'])
|
|
|
->setCellValue('B' . $rowIndex, $v['phone'])
|
|
|
->setCellValue('C' . $rowIndex, $v['prizeName'])
|
|
|
->setCellValue('D' . $rowIndex, $v['source'])
|
|
|
->setCellValue('E' . $rowIndex, $v['addTime']);
|
|
|
$rowIndex++;
|
|
|
}
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(25);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
|
|
|
|
|
|
$filename = '抽奖用户数据表';
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
|
|
|
|
$ua = $_SERVER["HTTP_USER_AGENT"];
|
|
|
header('Content-type: text/html; charset=gbk');
|
|
|
header("Content-type:application/vnd.ms-excel;charset=gbk");
|
|
|
//兼容IE11
|
|
|
if (preg_match("/MSIE/", $ua) || preg_match("/Trident\/7.0/", $ua)) {
|
|
|
header('Content-Disposition: attachment;filename="' . urlencode($filename) . '.xls"');
|
|
|
} else if (preg_match("/Firefox/", $ua)) {
|
|
|
header('Content-Disposition: attachment;filename*="' . $filename . '.xls"');
|
|
|
} else {
|
|
|
header('Content-Disposition: attachment; filename="' . $filename . '.xls"');
|
|
|
}
|
|
|
header('Cache-Control: max-age=0');
|
|
|
header('Cache-Control: max-age=1');
|
|
|
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
|
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
|
|
header('Cache-Control: cache, must-revalidate');
|
|
|
header('Pragma: public');
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
$objWriter->save('php://output');
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 重置抽奖次数
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function prize_reset(Request $request)
|
|
|
{
|
|
|
//$data = $request->param();
|
|
|
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeReset();
|
|
|
|
|
|
//$res = MCurl::instance($this->api_url."prizeReset")->post($data);
|
|
|
$json=json_decode($res,true);
|
|
|
if(is_numeric($json)){
|
|
|
$data=[
|
|
|
'code'=>200,
|
|
|
'msg'=>'重置成功'
|
|
|
];
|
|
|
}else{
|
|
|
$data=[
|
|
|
'code'=>100,
|
|
|
'msg'=>'重置失败'
|
|
|
];
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 规则设置 // 获取抽奖规则接口
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function prize_rule(Request $request)
|
|
|
{
|
|
|
//$data = $request->param();
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeRule();
|
|
|
//$res = MCurl::instance($this->api_url."prizeRule")->post($data);
|
|
|
$json=json_decode($res,true);
|
|
|
$code="fg5Fu7Is9aHJ5ug5".time();
|
|
|
$json['openid']=$code;
|
|
|
return $json;
|
|
|
// $json=json_encode($res);
|
|
|
// $aa= html_entity_decode($json);
|
|
|
// //数据特殊符号转义
|
|
|
// $aa = htmlspecialchars_decode($aa);
|
|
|
// return $aa;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 修改规则设置
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function prize_rule_edit(Request $request)
|
|
|
{
|
|
|
$data = $request->param();
|
|
|
//file_put_contents('aaqq.txt',$data);
|
|
|
//$data['title']=json_encode($data['title'],true);
|
|
|
$data['addTime']=time();
|
|
|
|
|
|
//return $data;
|
|
|
if(isset($data['open']) && $data['open']=="on"){
|
|
|
$data['open']=1;
|
|
|
}else{
|
|
|
$data['open']=0;
|
|
|
}
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeRuleEdit($data);
|
|
|
//$res = MCurl::instance($this->api_url."prizeRuleEdit")->post($data);
|
|
|
$json=json_decode($res,true);
|
|
|
|
|
|
if(is_numeric($json)){
|
|
|
$data=[
|
|
|
'code'=>200,
|
|
|
'msg'=>'修改成功'
|
|
|
];
|
|
|
}else{
|
|
|
$data=[
|
|
|
'code'=>100,
|
|
|
'msg'=>'修改失败'
|
|
|
];
|
|
|
}
|
|
|
return $data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 获取抽奖规则接口
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
|
|
|
public function prize_rule_api(Request $request)
|
|
|
{
|
|
|
$data = $request->param();
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeRuleEdit($data);
|
|
|
// $res = MCurl::instance($this->api_url."prizeRuleEdit")->post($data);
|
|
|
$json=json_decode($res,true);
|
|
|
if(is_numeric($json)){
|
|
|
$data=[
|
|
|
'code'=>200,
|
|
|
'msg'=>'重置成功'
|
|
|
];
|
|
|
}else{
|
|
|
$data=[
|
|
|
'code'=>100,
|
|
|
'msg'=>'重置失败'
|
|
|
];
|
|
|
}
|
|
|
return $data;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 首次进入 合适身份信息
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function sel_prize_member(Request $request)
|
|
|
{
|
|
|
$data = $request->param();
|
|
|
//给我 openID number
|
|
|
//查看当前用户是否存在
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->selPrizeMember($data);
|
|
|
|
|
|
return $res;
|
|
|
|
|
|
// //$res = MCurl::instance($this->api_url."selPrizeMember")->post($data);
|
|
|
// $json=json_decode($res,true);
|
|
|
// return $json;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 抽奖接口
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function luck_draw(Request $request)
|
|
|
{
|
|
|
//传递 openID prize_id
|
|
|
$data = $request->param();
|
|
|
|
|
|
//查看当前用户是否存在
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$json = $prize_win_model->luckDraw($data);
|
|
|
//$res = MCurl::instance($this->api_url."luckDraw")->post($data);
|
|
|
//$json=json_decode($res,true);
|
|
|
//传递 openID prize_id
|
|
|
return $json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 获取最新的20条中奖列表 / 个人的奖品列表
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function win_list(Request $request)
|
|
|
{
|
|
|
//传递 openID
|
|
|
$data = $request->param();
|
|
|
//查看当前用户是否存在
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->prizeWinList($data);
|
|
|
//$res = MCurl::instance($this->api_url."prizeWinList")->post($data);
|
|
|
$json=json_decode($res,true);
|
|
|
foreach($json as $key=>$val ){
|
|
|
$json[$key]['addTime']=date('Y-m-d H:i:s',$val['addTime']);
|
|
|
}
|
|
|
//传递 openID prize_id
|
|
|
return $json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 函数功能描述 兑奖接口
|
|
|
* Date: 2020/8/26
|
|
|
* Time: 10:00
|
|
|
* @author nyq
|
|
|
*/
|
|
|
public function cash_prize(Request $request)
|
|
|
{
|
|
|
//传递 openID
|
|
|
$data = $request->param();
|
|
|
//查看当前用户是否存在
|
|
|
$prize_win_model = new TurnPrizeModel();
|
|
|
$res = $prize_win_model->cashPrize($data);
|
|
|
//$res = MCurl::instance($this->api_url."cashPrize")->post($data);
|
|
|
$json=json_decode($res,true);
|
|
|
|
|
|
if($json==1){
|
|
|
$data=[
|
|
|
'code'=>200,
|
|
|
'msg'=>'成功'
|
|
|
];
|
|
|
}else{
|
|
|
$data=[
|
|
|
'code'=>100,
|
|
|
'msg'=>'失败'
|
|
|
];
|
|
|
}
|
|
|
|
|
|
//传递 openID prize_id
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发起GET请求
|
|
|
* @param string $url 请求地址
|
|
|
* @param array $data 请求参数
|
|
|
* @param string $cookiePath 请求所保存的cookie路径
|
|
|
*/
|
|
|
function curl_get($url, $data=[], $cookiePath = '')
|
|
|
{
|
|
|
if(count($data)!=0) {
|
|
|
$url = get_query_url($url, $data);
|
|
|
}
|
|
|
$ch = curl_init();
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath);
|
|
|
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath);
|
|
|
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
|
|
|
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
|
|
|
$res = curl_exec($ch);
|
|
|
curl_close($ch);
|
|
|
return $res;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|