Example #1
0
function showShippingInfo()
{
    $no = isset($_POST['ship_no']) ? $_POST['ship_no'] : '';
    $name = isset($_POST['ship_name']) ? $_POST['ship_name'] : '';
    $no = substr($no, 1);
    $info = Shipping::get($name, $no);
    if (!$info) {
        ABase::toJson(1, 'showShippingInfo : No Data');
    } else {
        ABase::toJson(0, 'ok', $info);
    }
}
Example #2
0
function signUp()
{
    $user = isset($_SESSION['user']) ? $_SESSION['user'] : null;
    if ($user) {
        header('Location: /');
        exit;
    }
    $user_phone = isset($_POST['userphone']) ? $_POST['userphone'] : null;
    if ($user_phone) {
        $user_phone = substr($user_phone, 1);
    }
    $yzm = isset($_POST['yzm']) ? (int) $_POST['yzm'] : 0;
    $signintoken = isset($_POST['sigtoken']) ? $_POST['sigtoken'] : null;
    $errormsg = '';
    if ($user_phone && $signintoken && strlen($user_phone) == 11 && Func::checkmobile($user_phone)) {
        $syzm = isset($_SESSION['dxyzm']) ? (int) $_SESSION['dxyzm'] : 0;
        $signin_token = isset($_SESSION['signin_token']) ? $_SESSION['signin_token'] : null;
        if ($yzm && $yzm === $syzm && $signintoken === $signin_token) {
            $enterprise_name = isset($_COOKIE['enterprise_name']) ? $_COOKIE['enterprise_name'] : null;
            if ($enterprise_name && 'null' != $enterprise_name) {
                $data['enterprise_name'] = $enterprise_name;
            }
            $data['identity'] = $identity = isset($_COOKIE['identity']) ? $_COOKIE['identity'] : null;
            $legal_identitys = isset($_COOKIE['legal_identity']) ? $_COOKIE['legal_identity'] : null;
            if ($legal_identitys && 'null' != $legal_identitys) {
                $data['legal_identity'] = $legal_identitys;
            }
            $data['legal_name'] = $legal_name = isset($_COOKIE['legal_name']) ? $_COOKIE['legal_name'] : null;
            $data['type'] = $type = isset($_POST['type']) ? $_POST['type'] : null;
            if (1 == $type) {
                if (!$enterprise_name || !$identity || !$legal_identitys || !$legal_name) {
                    ABase::toJson(1, '注册信息不完整');
                }
            } else {
                if (!$identity || !$legal_name) {
                    ABase::toJson(1, '注册信息不完整');
                }
            }
            $data['email'] = isset($_COOKIE['email']) ? $_COOKIE['email'] : null;
            $data['username_phone'] = $user_phone;
            $userid = Users::signUp($data);
            if ($userid) {
                $rdata['user_id'] = $userid;
                $rdata['module_id'] = 2;
                $rdata['receiver_name'] = $legal_name;
                $rdata['receiver_phone'] = $user_phone;
                $rdata['receiver_province'] = isset($_COOKIE['province']) ? $_COOKIE['province'] : 0;
                $rdata['receiver_city'] = isset($_COOKIE['city']) ? $_COOKIE['city'] : 0;
                $rdata['receiver_county'] = isset($_COOKIE['county']) ? $_COOKIE['county'] : 0;
                $rdata['receiver_address'] = isset($_COOKIE['address']) ? $_COOKIE['address'] : null;
                $rdata['receiver_postcode'] = isset($_COOKIE['postcode']) ? $_COOKIE['postcode'] : null;
                $receiver_address_id = ReceiverAddress::add($rdata);
                $user = Users::getData($userid);
                $utype = isset($user['type']) ? (int) $user['type'] : 0;
                $user_code = isset($user['user_code']) ? $user['user_code'] : '';
                $legal_name = isset($user['legal_name']) ? $user['legal_name'] : '';
                $enterprise_name = isset($user['enterprise_name']) ? $user['enterprise_name'] : '';
                $status = isset($user['status']) ? (int) $user['status'] : 0;
                $_SESSION['user'] = $user_phone;
                $_SESSION['userid'] = $userid;
                $_SESSION['user_code'] = $user_code;
                $_SESSION['usertype'] = $utype;
                $_SESSION['name'] = $utype ? $enterprise_name : $legal_name;
                $_SESSION['userstatus'] = $status;
                if (isset($_SESSION['tmp_user'])) {
                    unset($_SESSION['tmp_user']);
                }
                if (isset($_SESSION['dxyzm'])) {
                    unset($_SESSION['dxyzm']);
                }
                if (isset($_SESSION['signin_token'])) {
                    unset($_SESSION['signin_token']);
                }
                if (isset($_SESSION['signin_num'])) {
                    unset($_SESSION['signin_num']);
                }
                if (isset($_SESSION['dxyzm_send_num'])) {
                    unset($_SESSION['dxyzm_send_num']);
                }
                if ($receiver_address_id) {
                    Users::update($userid, array('receiver_address_id' => $receiver_address_id));
                }
                ABase::toJson(0, 'ok');
            } else {
                ABase::toJson(1, '注册失败,请重试');
            }
        } else {
            ABase::toJson(1, '验证码错误');
        }
    } else {
        $type = isset($_GET['t']) ? (int) $_GET['t'] : 0;
        //0:个人,1:企业
        $step = isset($_GET['s']) ? (int) $_GET['s'] : 1;
        //下一步
        if ($step < 1) {
            $step = 1;
        }
        $tmp_user = isset($_SESSION['tmp_user']) ? $_SESSION['tmp_user'] : '';
        //保存在输入框的临时信息
        $tmp_get_yzm = isset($_SESSION['tmp_get_yzm']) ? (int) $_SESSION['tmp_get_yzm'] : 0;
        //重复点击获取验证码按钮刷新后的自动触发
        if (isset($_SESSION['tmp_get_yzm'])) {
            unset($_SESSION['tmp_get_yzm']);
        }
        $provinces = Countys::getCountys();
        $token = ABase::token();
        $signin_token = $_SESSION['signin_token'] = Func::getRandomCode(30);
        $user = isset($_SESSION['user']) ? $_SESSION['user'] : null;
        Templates::Assign('user', $user);
        Templates::Assign('tmp_user', $tmp_user);
        Templates::Assign('tmp_get_yzm', $tmp_get_yzm);
        Templates::Assign('provinces', $provinces);
        Templates::Assign('type', $type);
        Templates::Assign('step', $step);
        Templates::Assign('token', $token);
        Templates::Assign('signin_token', $signin_token);
        Templates::Assign('errormsg', $errormsg);
        Templates::Display('signup.html');
    }
}
Example #3
0
            if (!$sku_id) {
                ABase::toJson(1, 'error 001');
            }
            if (Favorite::add($userid, $sku_id)) {
                ABase::toJson(0, 'ok');
            }
            ABase::toJson(1, 'error 009');
            break;
        case 'remove':
            $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
            if ($id) {
                if (Favorite::del($id)) {
                    ABase::toJson(0, 'ok');
                } else {
                    ABase::toJson(1, 'error 010');
                }
            }
            ABase::toJson(1, 'error 011');
            break;
        default:
            ABase::toJson(1, 'action error');
    }
} else {
    $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
    $page_size = isset($_GET['page_size']) ? (int) $_GET['page_size'] : 16;
    $favorites = Favorite::getLists($userid, $page, $page_size);
    //var_dump($favorites);exit;
    Templates::Assign('favorites', $favorites['data']);
    Templates::Assign('paged', $favorites['page']);
    Templates::Display('favorite.html');
}
Example #4
0
function save($userid, $addrid = 0)
{
    $n = isset($_REQUEST['n']) ? (int) $_REQUEST['n'] : 0;
    $rdata['user_id'] = $userid;
    $rdata['module_id'] = 2;
    $rdata['receiver_name'] = $name = isset($_POST['truename']) ? $_POST['truename'] : '';
    $phone = isset($_POST['mmobile']) ? $_POST['mmobile'] : '';
    if ($phone) {
        $rdata['receiver_phone'] = substr($phone, 1);
    }
    $rdata['receiver_province'] = $province = isset($_POST['province']) ? $_POST['province'] : 0;
    $rdata['receiver_city'] = $city = isset($_POST['city']) ? $_POST['city'] : 0;
    $rdata['receiver_county'] = $county = isset($_POST['county']) ? $_POST['county'] : 0;
    $rdata['receiver_address'] = $address = isset($_POST['address']) ? $_POST['address'] : '';
    $rdata['receiver_postcode'] = $postcode = isset($_POST['postcode']) ? $_POST['postcode'] : '';
    $setDefault = isset($_POST['setDefault']) ? $_POST['setDefault'] : '';
    //var_dump($rdata); exit;
    if (!$name || !$phone || !$province || !$city || !$county || !$address) {
        if (!$n) {
            header("Location: /address");
            exit;
        }
        ABase::toJson(1, 'error 001');
    }
    if (!$addrid) {
        $receiver_address_id = ReceiverAddress::add($rdata);
    } else {
        unset($rdata['user_id'], $rdata['module_id']);
        ReceiverAddress::update($addrid, $rdata);
        $receiver_address_id = $addrid;
    }
    if ($setDefault) {
        ReceiverAddress::setDefault($userid, $receiver_address_id);
    }
    if (!$n) {
        header("Location: /address");
        exit;
    }
    $data = ReceiverAddress::getInfo($receiver_address_id);
    ABase::toJson(0, 'ok', $data);
}
Example #5
0
 static function RSASignature($plaintext, $url)
 {
     if (!$plaintext || !$url) {
         return '0,error001';
     }
     if (!($sign = RSA::ssoSignature($plaintext))) {
         ABase::toJson(0, 'Create signature failed');
     }
     //------------------------ CURL post
     $data = array('plaintext' => $plaintext, 'md' => $sign);
     $encoded = "";
     foreach ($data as $k => $v) {
         $encoded .= $encoded ? '&' : '';
         $encoded .= rawurlencode($k) . "=" . rawurlencode($v);
     }
     $pcontent = Func::curlPost($url, $encoded);
     return $pcontent;
 }
Example #6
0
function orderNotify()
{
    $orders = Orders::publicPayOrderSignVerify();
    $order_code = isset($orders['order_code']) ? $orders['order_code'] : '';
    $order_id = isset($orders['id']) ? (int) $orders['id'] : 0;
    $order_status = isset($orders['order_status']) ? (int) $orders['order_status'] : 0;
    $pay_transaction_id = isset($orders['pay_transaction_id']) ? $orders['pay_transaction_id'] : '';
    $paid = isset($orders['paid']) ? $orders['paid'] : 0;
    $paymethod_code = $orders['paymethod_code'];
    if (1 == $order_status) {
        $pay_method = PaymentMethod::getOne(array('code' => $paymethod_code), 'id');
        $pay_method = isset($pay_method['id']) ? (int) $pay_method['id'] : 0;
        $sk_order_code = null;
        $order_type = substr($order_code, -2, 2);
        if ('YK' == $order_type) {
            $sk_order_code = str_replace('YK', 'SK', $order_code);
        }
        DB::tranBegin('notify');
        //事务开始
        Orders::update(array('order_code' => $order_code), array('paid' => $paid, 'order_status' => 2, 'pay_method' => $pay_method, 'pay_transaction_id' => $pay_transaction_id, 'pay_time' => time()));
        if ($sk_order_code) {
            Orders::update(array('order_code' => $sk_order_code), array('order_status' => 5));
        }
        ProductsStockLock::changeStatus($order_code, 1);
        OrdersProducts::updateOrderProductStock($order_code);
        $commit_status = DB::tranEnd('notify');
        if (!$commit_status) {
            ABase::toJson(1, 'FAIL', $orders);
        }
    }
    ABase::toJson(0, 'SUCCESS', $orders);
}
Example #7
0
//先把状态改成 订单取消,回滚完库存把状态改成7:订单关闭
ABase::log("Order ids in 1 hour : " . serialize($ids), 'cron_');
$time = time() - 10800;
//3小时前的订单库存回收,考虑订单生成后还差一分钟订单失效时用户点击付款,并在付款操作时又等待了2小时
$orders = Orders::getList("create_time<{$time} AND order_status=6", 'id,order_code');
//首先在1个小时内使订单失效
foreach ($orders as $k => $order) {
    $oid = $order['id'];
    $order_code = $order['order_code'];
    $order_type = substr($order_code, -2, 2);
    if ('SK' != $order_type) {
        unset($orders[$k]);
        continue;
    }
    //DB::Debug();
    $stocks = ProductsStockLock::getList("order_code='{$order_code}' AND status=0");
    ABase::log("Stocks in 3 hour order: " . serialize($stocks), 'cron_');
    DB::tranBegin('stock_recycle');
    foreach ($stocks as $stock) {
        $sid = $stock['id'];
        $product_sku = $stock['product_sku'];
        $product_num = $stock['product_num'];
        $exp_date = $stock['exp_date'];
        ProductsStock::increase("product_sku='{$product_sku}' AND exp_date='{$exp_date}'", "stock", $product_num);
        ProductsStockLock::update($sid, array('status' => 2));
    }
    Orders::update($oid, array('order_status' => 7));
    $commit_status = DB::tranEnd('stock_recycle');
}
ABase::log("Orders in 3 hour : " . serialize($orders), 'cron_');
//---------- END 过期未支付订单库存回收
Example #8
0
$total = 0.0;
foreach ($product_ids as $sku_id => $product_id) {
    $qt = isset($qts[$sku_id]) ? (int) $qts[$sku_id] : 0;
    if ($qt < 1) {
        continue;
    }
    $skus[$sku_id]['qt'] = $qt;
    $skus[$sku_id]['info'] = $info = ProductsSku::getData($sku_id);
    $current_price = isset($info['current_price']) ? $info['current_price'] : 0.0;
    $pic = ProductsPic::getOne(array('sku' => $info['sku']), 'path', 'sort DESC');
    $skus[$sku_id]['info']['pic'] = $pic['path'];
    $item = ProductsSku::getSkuItem($info['item'], 'title');
    $skus[$sku_id]['info']['title'] = $item['title'];
    $total = $total + $qt * $current_price;
}
//var_dump($product_ids,$skus);exit;
$userlevel = Users::getLevel($userid);
$discount = $userlevel['discount'];
$newtotal = $total * $discount;
$address = ReceiverAddress::getInfoByUser($userid);
//var_dump($address);
$yunfei = 0.0;
$token = ABase::token();
Templates::Assign('yunfei', $yunfei);
Templates::Assign('token', $token);
Templates::Assign('address', $address);
Templates::Assign('userlevel', $userlevel);
Templates::Assign('newtotal', $newtotal);
Templates::Assign('total', $total);
Templates::Assign('skus', $skus);
Templates::Display('buy.html');
Example #9
0
        return $article;
    }
}
class Snatch extends SiteScraper
{
    function getArticle($keyword)
    {
        $keyword = str_replace(" ", "+", $keyword);
        $article = $this->makeArticle("http://www.google.com/cse?cx=partner-pub-2050911826501646%3A1m6ue6-c897&cof=FORID%3A10&ie=ISO-8859-1&q={$keyword}&sa=Search&siteurl=www.articlesnatch.com%2F&ad=w9&num=10&rurl=http%3A%2F%2Fwww.articlesnatch.com%2Fcse.php%3Fcx%3Dpartner-pub-2050911826501646%253A1m6ue6-c897%26cof%3DFORID%253A10%26ie%3DISO-8859-1%26q%3Dcats%26sa%3DSearch%26siteurl%3Dwww.articlesnatch.com%252F%26siteurl%3Dwww.articlesnatch.com%252F", 'div[class=articletext]');
        $article = $this->stripJS($article);
        return $article;
    }
}
class ABase extends SiteScraper
{
    function makeSearchLink($articleUrl)
    {
        $htmlContents = $this->getHtml($articleUrl);
        $links = $this->getAllLinks($htmlContents);
        $links = array_filter($links, array($this, 'endsWithHtml'));
        return $links[array_rand($links)];
    }
    function getArticle($keyword)
    {
        $keyword = str_replace(" ", "+", $keyword);
        $article = $this->makeArticle("http://www.articlesbase.com/find-articles.php?q={$keyword}", 'div[class=article_cnt KonaBody]');
        return $article;
    }
}
$n = new ABase();
print_r($n->getArticle("pink floyd"));
Example #10
0
 public static function cancelOrder($order_code, $user)
 {
     $order_type = substr($order_code, -2, 2);
     if ('SK' != $order_type) {
         return false;
     }
     $order = Orders::getOne(array('order_code' => $order_code), 'id, order_status');
     if (1 != $order['order_status']) {
         return false;
     }
     $oid = $order['id'];
     //DB::Debug();
     $stocks = ProductsStockLock::getList("order_code='{$order_code}' AND status=0");
     ABase::log("Stocks in cancelOrder: " . serialize($stocks), 'cancel_order_');
     DB::tranBegin('Orders.cancelOrder');
     //事务开始
     OrdersLog::insert(array('order_code' => $order_code, 'ex_status' => '取消订单', 'admin' => $user, 'action' => '订单取消', 'ip' => Func::getIP(), 'create_time' => time()));
     foreach ($stocks as $stock) {
         $sid = $stock['id'];
         $product_sku = $stock['product_sku'];
         $product_num = $stock['product_num'];
         $exp_date = $stock['exp_date'];
         ProductsStock::increase("product_sku='{$product_sku}' AND exp_date='{$exp_date}'", "stock", $product_num);
         ProductsStockLock::update($sid, array('status' => 2));
     }
     Orders::update($oid, array('order_status' => 7));
     $commit_status = DB::tranEnd('Orders.cancelOrder');
 }
Example #11
0
$rate = isset($REQUEST['rate']) ? floatval($REQUEST['rate']) : 0.5;
//付款比率,1全款,0.5半款
$redirect = 0;
$order_id = 0;
$commit_status = 0;
$locked = 0;
if (!$order_code) {
    $addressid = isset($_POST['address']) ? (int) $_POST['address'] : 0;
    $sku_ids = isset($_POST['sku_ids']) ? $_POST['sku_ids'] : array();
    $token = isset($_POST['token']) ? $_POST['token'] : '';
    if (!$addressid || !$sku_ids || !$token) {
        Templates::Assign('errormsg', "参数传输错误。");
        Templates::Display('error.html');
        exit;
    }
    if (!ABase::token($token)) {
        Templates::Assign('errormsg', "请勿重复提交订单");
        Templates::Display('error.html');
        exit;
    }
    $device = strtoupper(str_replace(DS, '', _DEVICE));
    $order_code = "FX" . $device . date('ymdHis') . rand(10, 99) . 'SK';
    //首款订单,银联支付限制订单号20位
    $user_level = Users::getLevel($userid);
    $discount = (double) $user_level['discount'];
    $total = 0.0;
    $title = '';
    foreach ($sku_ids as $sku_id => $qt) {
        $qt = (int) $qt;
        if ($qt < 1) {
            continue;