|
- <?php
- require_once '../Common/Config.php';
- require_once '../Common/Function.php';
- $pdo = new PDO("sqlsrv:Server=".HOST.";Database=".DB, USER, PASSWORD);//5.6版本pdo连接sqlsrv
- if ($_POST){
- $method=htmlspecialchars($_POST['method']);
- if ($method =='shareTimeLine'){
-
-
- $sharTimeLine=htmlspecialchars($_POST['shareTimeLine']);
-
- if ($sharTimeLine ==0){
- $updateId=htmlspecialchars($_POST['updateId']);
- $openId=htmlspecialchars($_POST['openId']);
- $sql="SELECT sharTimeLine FROM lottery_user WHERE openId='".$openId."'";
- $result=$pdo->query($sql);
- $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
- $sharTime=$rowset[0]['sharTimeLine'];
- if ($sharTime !=0){
- exit;
- }
- write_log("method:shareTimeLine有调用");
- $addCode="SELECT TOP 1 id,lotteryCode FROM lottery_code";
- $addResult=$pdo->query($addCode);
- $addRowset = $addResult->fetchAll(PDO::FETCH_ASSOC);
- $addErrinfo=$pdo->errorInfo();
- if ($addErrinfo[0] =="00000"){
- $addLotteryCode=$addRowset[0]['lotteryCode'];
- $addId=$addRowset[0]['id'];
- //$id=2;
- $updateSql="UPDATE lottery_user SET sharTimeLine=1 WHERE id=".$updateId;
- write_log($updateSql);
- $updateResult=$pdo->exec($updateSql);
- $insertSql="INSERT INTO lottery_friends(openId,lotteryCode,createtime) VALUES('".$openId."',".$addLotteryCode.",'".date("Y-m-d H:i:s",time())."')";
- $insertResult=$pdo->exec($insertSql);
- $delSql="DELETE FROM lottery_code WHERE id=".$addId;
- $delResult=$pdo->exec($delSql);
- $result= json_encode(array("errorcode"=>0,"errorcode"=>"分享朋友圈成功"));
- }
- }else{
- $result= json_encode(array("errorcode"=>0,"errorcode"=>"多次分享朋友圈只能获得一个抽奖码"));
- }
- }
- echo $result;
- }
-
- ?>
|