|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /*
- file: shop.php 購物
- */
- class Shop extends CC_Controller
- {
- function __construct()
- {
- parent::__construct('shop');
- }
-
- // 首頁
- public function index()
- {
- $this->show_page('main_page');
- }
-
- // 咖啡包預覽頁
- public function coffee_shop()
- {
- $product_id = $this->uri->segment(3); // 商品代碼
- $data = $this->app_model()->q_product($product_id);
- unset($data['product_plan']);
- $this->show_page('main_page', $data);
- }
-
- // 付款
- public function transfer_money()
- {
- $product_id = $this->input->post('product_id', true);
- $product_code = $this->input->post('product_code', true);
- $invoice_receiver = $this->input->post('invoice_receiver', true);
- $company_no = $this->input->post('company_no', true);
- $email = $this->input->post('email', true);
- $mobile = $this->input->post('mobile', true);
-
- // 建立訂單
- $new_bill = $this->app_model()->create_product_bill($product_id, $product_code);
-
- if(!isset($new_bill['order_no']))
- {
- echo 'bill_create_fail';
- exit;
- }
-
- $parms = array(
- 'order_no' => $new_bill['order_no'],
- 'invoice_receiver' => $invoice_receiver,
- 'company_no' => $company_no,
- 'email' => $email,
- 'mobile' => $mobile
- );
-
- // 處理產品訂單
- $proceed_bill = $this->app_model()->proceed_product_bill($parms, 50); // 50: 歐付寶刷卡
-
- // 開始進行繳交帳單
- if(!isset($proceed_bill['status']) || $proceed_bill['status'] != 100)
- {
- echo 'bill_proceed_fail';
- exit;
- }
-
- // 串接總公司購物流程
- $proceed_bill['station_no'] = $this->get_station_no();
- $proceed_bill['product_id'] = $product_id;
- $proceed_bill['product_code'] = $product_code;
- trigger_error(__FUNCTION__ . '..' . print_r($proceed_bill, true));
-
- try{
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://parks.altob.com.tw/bill_service.html/proceed_bill'); // 金流
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,30);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout in seconds
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($proceed_bill));
- $result = curl_exec($ch);
-
- if(curl_errno($ch))
- {
- trigger_error(__FUNCTION__ . ', curl error: '. curl_error($ch));
- }
-
- curl_close($ch);
-
- }catch (Exception $e){
- trigger_error(__FUNCTION__ . 'error:'.$e->getMessage());
- }
-
- echo $result;
- }
-
- // 買
- public function i_do()
- {
- $product_id = $this->uri->segment(3); // 商品代碼
- $data = $this->app_model()->q_coffee_shop($product_id);
-
- trigger_error(__FUNCTION__ . '..' . print_r($data, true));
-
-
- echo 'ok';
- }
-
- }
|