示例#1
0
 public function __construct()
 {
     parent::__construct();
     $this->userId = $this->CI->session->userdata('userId');
     $this->bmobObject = new BmobObject('Cart');
     if (!empty($this->userId)) {
         //在bmob上生成一条购物车记录
         try {
             //bmob上已设置userId字段唯一
             $res = $this->bmobObject->create(array('userId' => $this->userId, 'items' => ''));
             $this->cartId = $res->objectId;
         } catch (Exception $e) {
             $res = $this->bmobObject->get('', array('where={"userId":"' . $this->userId . '"}', 'limit=1'));
             $res = $res->results[0];
             $this->cartId = $res->objectId;
         }
     }
 }
示例#2
0
 public function __construct($orderId = '')
 {
     parent::__construct();
     $this->userId = $this->CI->session->userdata('userId');
     $this->cart = new MY_Cart();
     $this->bmobOrder = new BmobObject('Order');
     //引入ping++
     require_once APPPATH . 'third_party/pingpp/init.php';
     $test_key = 'sk_test_0CKaPS8CmDeLfr9CCOmXHGGS';
     $live_key = 'sk_live_bOz9YlaOHrS7dFw9yYlUif7R';
     $this->pingpp_app_id = 'app_SO0anHPWznHCbL0y';
     \pingpp\Pingpp::setApiKey($live_key);
     //订单号不为空,则从bomb拉去信息
     if (!empty($orderId)) {
         $this->orderId = $orderId;
         $res = $this->bmobOrder->get($orderId);
         $orderInfo = $res->results[0];
         $this->totalPrice = $orderInfo->totalPrice;
     }
 }