public function makeGuess($requestObj)
 {
     $game = AppConfig::GAME;
     $customer = null;
     $openid = $requestObj->openid;
     if (null === $openid || 'null' === $openid || '' === trim($openid)) {
         $openid = 'FakeId';
     }
     if (null != $openid && "" != trim($openid)) {
         $customerPDO = new CustomerPDO();
         $guessPDO = new GuessPDO();
         $customer = $customerPDO->findByOpenId($openid);
         $guess = $guessPDO->findByOpenIdAndGame($openid, $game);
         $userid = null == $customer ? null : $customer->id;
         if ($customer == null) {
             $id = $customerPDO->insertSingleRow($openid);
             if ($id > 0) {
                 $userid = $id;
                 //                    echo json_encode(array('success'=>true, 'type'=>'info', 'request'=>$requestObj, 'test'=>$userid, 'object'=>$customer, 'message'=>"Successfully inserted "));
             }
             //                else {
             //                    echo json_encode(array('success'=>false, 'type'=>'error', 'request'=>$requestObj, 'test'=>$userid, 'object'=>$customer, 'message'=>"Error Occur "));
             //                }
             //                echo json_encode(array('test'=>$id));
         }
         //            else {
         //                echo json_encode(array('success'=>true, 'type'=>'info', 'request'=>$requestObj, 'test'=>$userid, 'object'=>$customer, 'message'=>"Customer Exist "));
         //            }
         if ($guess == null) {
             //                echo json_encode(array('success'=>true, 'type'=>'info', 'request'=>$requestObj, 'racerTeam'=>$racerTeam, 'object'=>$guess, 'message'=>"Successfully updated "));
             $v = explode('-', $requestObj->data->racerChoice);
             $racerTeam = $v[0];
             $racer = end($v);
             $v = explode('-', $requestObj->data->pubChoice);
             $pubLocation = $v[0];
             $pub = end($v);
             $purchaseCode = $requestObj->data->purchaseCode;
             if (!is_null($purchaseCode) && is_string($purchaseCode)) {
                 $purchaseCode = strtoupper($purchaseCode);
             }
             $cellphone = $requestObj->data->cellphone;
             if ($guessPDO->insertSingleRow($userid, $openid, $game, $racerTeam, $racer, $pubLocation, $pub, $purchaseCode, $cellphone)) {
                 echo json_encode(array('success' => true, 'type' => 'info', 'request' => $requestObj, 'test' => $userid, 'object' => $guess, 'message' => "Successfully updated "));
             } else {
                 echo json_encode(array('success' => false, 'type' => 'error', 'request' => $requestObj, 'object' => $guess, 'message' => "Error Occur "));
             }
         } else {
             echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E001', 'request' => $requestObj, 'test' => $userid, 'object' => $guess, 'message' => "您已提交过竞猜。<br>每位客户每站比赛只能提交一次竞猜"));
         }
     } else {
         echo json_encode(array('success' => false, 'type' => 'info', 'request' => $requestObj, 'object' => null, 'message' => "Invalid Open Id [" . $openid . "]"));
     }
 }
Esempio n. 2
0
 public function checkGuess($requestObj)
 {
     $game = AppConfig::GAME;
     $customer = null;
     $openid = $requestObj->openid;
     if (null === $openid || 'null' === $openid || '' === trim($openid)) {
         $openid = 'FakeId';
     }
     if (null != $openid && "" != trim($openid)) {
         $guessPDO = new GuessPDO();
         $guess = $guessPDO->findBingo($openid, AppConfig::GAME);
         if (null !== $guess) {
             echo json_encode(array('success' => true, 'type' => 'info', 'request' => $requestObj, 'object' => $guess, 'message' => "Successfully updated "));
         } else {
             echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E001', 'request' => $requestObj, 'object' => $guess, 'message' => "抱歉,您未中奖!<br>请参照竞猜则重新竞猜"));
         }
     } else {
         echo json_encode(array('success' => false, 'type' => 'info', 'request' => $requestObj, 'object' => null, 'message' => "Invalid Open Id [" . $openid . "]"));
     }
 }
Esempio n. 3
0
 public function testCashLottery($requestObj)
 {
     $game = AppConfig::GAME_TEST;
     $customer = null;
     $pubCode = $requestObj->pubCode;
     $pubPDO = new PubPDO();
     if (null === $pubCode || 'null' === $pubCode || '' === trim($pubCode)) {
         $pubCode = 'FakePubCode';
     }
     $pub = null;
     if (null != $pubCode && "" != trim($pubCode)) {
         $pub = $pubPDO->findPub($pubCode);
         if (null === $pub) {
             echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E002', 'request' => $requestObj, 'object' => null, 'message' => "酒吧识别码无效(" . $pubCode . ")<br>请正确填写!"));
             return;
         } else {
             if ((int) $pub->promoted_gift_amount >= 10) {
                 echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E003', 'request' => $requestObj, 'object' => null, 'message' => "非常抱歉,您来晚了<br>本店所有礼品已送出!"));
                 return;
             }
         }
     } else {
         echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E002', 'request' => $requestObj, 'object' => null, 'message' => "酒吧识别码无效(" . $pubCode . ")<br>请正确填写!"));
         return;
     }
     $cellphone = $requestObj->cellphone;
     //        echo json_encode(array('success'=>true, 'type'=>'info', 'request'=>$requestObj, 'object'=>$cellphone, 'message'=>"Successfully updated "));
     if (null === $cellphone || 'null' === $cellphone || '' === trim($cellphone)) {
         $cellphone = 'FakeCellPhone';
     }
     if (null != $cellphone && "" != trim($cellphone)) {
         $guessPDO = new GuessPDO();
         $guess = $guessPDO->findBingoCellphone($cellphone, AppConfig::GAME_TEST);
         if (null !== $guess) {
             $pubName = null != $pub->pub ? trim($pub->pub) : "";
             $guessPubName = null != $guess->pub ? trim($guess->pub) : "";
             if (strcmp($pubName, $guessPubName) !== 0) {
                 echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E005', 'request' => $requestObj, 'object' => $guess, 'message' => "抱歉,您不是在本酒吧参与竞猜,无法兑奖!<br>请联系工作人员"));
                 return;
             }
             $pubPDO->updatePubStorage($pubCode);
             $cashPDO = new CashPDO();
             if ($cashLog = $cashPDO->findCashLog($cellphone)) {
                 echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E004', 'request' => $requestObj, 'object' => $guess, 'message' => "抱歉,您已兑换过礼品<br>请勿重复兑奖!"));
                 return;
             }
             $name = $requestObj->name;
             $address = $requestObj->address;
             $mail = $requestObj->mail;
             $cashPDO->insertSingleRow(null, $cellphone, $name, $address, $mail);
             echo json_encode(array('success' => true, 'type' => 'info', 'request' => $requestObj, 'object' => $requestObj->name, 'message' => "Successfully updated "));
         } else {
             echo json_encode(array('success' => false, 'type' => 'warn', 'code' => 'E001', 'request' => $requestObj, 'object' => $guess, 'message' => "抱歉,您未中奖<br>或者您输入的手机号码有误"));
         }
     } else {
         echo json_encode(array('success' => false, 'type' => 'info', 'request' => $requestObj, 'object' => null, 'message' => "Invalid Open Id [" . $cellphone . "]"));
     }
 }