Esempio n. 1
0
 public function home()
 {
     global $db, $config, $scodeModel;
     // 初始化資料庫連結介面
     $db = new mysql($config["db"]);
     $db->connect();
     $scodeModel = new ScodeModel();
     $this->str = new convertString();
     $ret['status'] = 0;
     if (empty($_POST['scsn']) || empty($_POST['scpw'])) {
         //S码序号、S码密码不能空白
         $ret['status'] = 2;
     } else {
         $query = "SELECT * \r\n\t\t\tFROM `{$config['db'][1]['dbname']}`.`{$config['default_prefix']}scode_item` \r\n\t\t\tWHERE \r\n\t\t\t\tprefixid = '{$config['default_prefix_id']}' \r\n\t\t\t\tAND serial = '{$_POST['scsn']}' \r\n\t\t\t\tAND switch = 'Y' \r\n\t\t\t";
         $table = $db->getQueryRecord($query);
         $scode_item = isset($table['table']['record'][0]) ? $table['table']['record'][0] : '';
         if (empty($scode_item)) {
             //'不存在'
             $ret['status'] = 3;
         } elseif ($_POST['scpw'] !== $scode_item['pwd']) {
             //'密码错误'
             $ret['status'] = 4;
         } elseif ($scode_item['verified'] == 'Y') {
             //已激活
             $ret['status'] = 5;
         }
     }
     if (empty($ret['status'])) {
         //S码激活
         $query = "UPDATE `{$config['db'][1]['dbname']}`.`{$config['default_prefix']}scode_item` \r\n\t\t\tSET `verified`='Y', userid='{$_SESSION['auth_id']}'\r\n\t\t\tWHERE \r\n\t\t\t\t`prefixid` = '{$config['default_prefix_id']}'\r\n\t\t\t\tAND serial = '{$_POST['scsn']}'\r\n\t\t\t";
         $db->query($query);
         //實體S碼序號
         $scode_promote['spid'] = $scode_item['spid'];
         $scode_promote['behav'] = 'e';
         $scode_promote['promote_amount'] = 1;
         $scode_promote['num'] = $scode_item['amount'];
         //插入S碼收取記錄
         $scodeModel->insert_scode($scode_promote, $_SESSION['auth_id'], $_POST['scsn']);
         //回傳:
         $ret['status'] = 200;
     }
     echo json_encode($ret);
 }
Esempio n. 2
0
    $row_scode = $row['table']['record'][0];
}
//查驗藍新支付寶銷帳狀態
$order = queryOrder($config, $table['table']['record']);
if (empty($order) || $order['status'] != 1 || $order['merchantnumber'] != $config['alipay']['merchantnumber'] || $order['ordernumber'] != $table['table']['record'][0]['dhid']) {
    die;
} else {
    if ($row_scode) {
        //會員充值滿額送S碼
        $scodeModel = new ScodeModel();
        $scode_promote['spid'] = $row_scode['spid'];
        $scode_promote['behav'] = 'c';
        $scode_promote['promote_amount'] = $row_scode['num'];
        $scode_promote['num'] = $row_scode['amount'];
        //插入S碼收取記錄
        $scodeModel->insert_scode($scode_promote, $table['table']['record'][0]['userid'], $row_scode['spname']);
    }
    $query = "INSERT INTO `{$config['db'][1]['dbname']}`.`{$config['default_prefix']}deposit`\n\t\tSET\n\t\t\t `prefixid`='{$config['default_prefix_id']}',\n\t\t\t `userid`='{$table['table']['record'][0]['userid']}', \n\t\t\t `countryid`='{$config['country']}', \n\t\t\t `behav`='user_deposit', \n\t\t\t `currency`='{$currency}',\n\t\t\t `amount`='{$table['table']['record'][0]['amount']}', \n\t\t\t `insertt`=NOW()\n\t\t";
    $db->query($query);
    $depositid = $db->_con->insert_id;
    if (!empty($table['table']['record'][0]['spointid'])) {
        $spointid = $table['table']['record'][0]['spointid'];
    } else {
        $query = "INSERT INTO `{$config['db'][1]['dbname']}`.`{$config['default_prefix']}spoint`\n\t\t  SET\n\t\t\t   `prefixid`='{$config['default_prefix_id']}',\n\t\t\t   `userid`='{$table['table']['record'][0]['userid']}', \n\t\t\t   `countryid`='{$config['country']}',\n\t\t\t   `behav`='user_deposit', \n\t\t\t   `amount`='{$table['table']['record'][0]['spoint']}', \n\t\t\t   `insertt`=NOW()\n\t\t  ";
        $db->query($query);
        $spointid = $db->_con->insert_id;
    }
    $query = "UPDATE `{$config['db'][1]['dbname']}`.`{$config['default_prefix']}deposit_history`\n\t\tSET \n\t\t\tdata      = '" . json_encode($_POST) . "',\n\t\t\tstatus    = 'deposit',\n\t\t\tspointid  = '{$spointid}',\n\t\t\tdepositid = '{$depositid}'\n\t\tWHERE \n\t\t\tprefixid   = '{$config['default_prefix_id']}' \n\t\t\tAND dhid   = '{$ordernumber}'\n\t\t\tAND status = 'order'\n\t\t\tAND switch = 'Y'\n\t\t";
    $db->query($query);
}
//查驗藍新支付寶銷帳狀態