VM暫存
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Shop.php 4.1KB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /*
  3. file: shop.php 購物
  4. */
  5. class Shop extends CC_Controller
  6. {
  7. function __construct()
  8. {
  9. parent::__construct('shop');
  10. }
  11. // 首頁
  12. public function index()
  13. {
  14. $this->show_page('main_page');
  15. }
  16. // 付款流程頁面 (返回)
  17. public function client_back()
  18. {
  19. trigger_error(__FUNCTION__ . '..'. print_r($_POST, true));
  20. $this->show_page('main_page');
  21. }
  22. // 付款流程頁面 (完成, 返回)
  23. public function order_result()
  24. {
  25. trigger_error(__FUNCTION__ . '..'. print_r($_POST, true));
  26. $order_no = $this->input->post('order_no', true);
  27. $product_plan = $this->input->post('product_plan', true);
  28. $invoice_no = $this->input->post('invoice_no', true);
  29. $ck = $this->input->post('ck', true);
  30. // 建立頁面資料
  31. $data = array();
  32. $data['invoice_no'] = $invoice_no;
  33. // 更新產品訂單
  34. if($ck = md5($order_no.'alt'.$product_plan.'ob'.$invoice_no))
  35. {
  36. $this->app_model()->reload_product_bill($order_no, $invoice_no, $product_plan);
  37. // 取得發票待兌換訂單
  38. //$data['invoice_ready_bill'] = $this->app_model()->q_invoice_ready_bill($invoice_no);
  39. }
  40. $this->show_page('main_page', $data);
  41. }
  42. // 咖啡包預覽頁
  43. public function coffee_shop()
  44. {
  45. $product_id = $this->uri->segment(3); // 商品代碼
  46. $data = $this->app_model()->q_product($product_id);
  47. unset($data['product_plan']);
  48. $this->show_page('main_page', $data);
  49. }
  50. // 付款
  51. public function transfer_money()
  52. {
  53. $product_id = $this->input->post('product_id', true);
  54. $product_code = $this->input->post('product_code', true);
  55. $invoice_receiver = $this->input->post('invoice_receiver', true);
  56. $company_no = $this->input->post('company_no', true);
  57. $email = $this->input->post('email', true);
  58. $mobile = $this->input->post('mobile', true);
  59. // 建立訂單
  60. $new_bill = $this->app_model()->create_product_bill($product_id, $product_code);
  61. if(!isset($new_bill['order_no']))
  62. {
  63. echo 'bill_create_fail';
  64. exit;
  65. }
  66. $parms = array(
  67. 'order_no' => $new_bill['order_no'],
  68. 'invoice_receiver' => $invoice_receiver,
  69. 'company_no' => $company_no,
  70. 'email' => $email,
  71. 'mobile' => $mobile
  72. );
  73. // 處理產品訂單
  74. $proceed_bill = $this->app_model()->proceed_product_bill($parms, 50); // 50: 歐付寶刷卡
  75. // 開始進行繳交帳單
  76. if(!isset($proceed_bill['status']) || $proceed_bill['status'] != 100)
  77. {
  78. echo 'bill_proceed_fail';
  79. exit;
  80. }
  81. // 串接總公司購物流程
  82. $proceed_bill['station_no'] = $this->get_station_no();
  83. $proceed_bill['product_id'] = $product_id;
  84. $proceed_bill['product_code'] = $product_code;
  85. $proceed_bill['client_back_path'] = 'shop.html/client_back';
  86. $proceed_bill['order_result_path'] = 'shop.html/order_result';
  87. trigger_error(__FUNCTION__ . '..' . print_r($proceed_bill, true));
  88. try{
  89. $ch = curl_init();
  90. curl_setopt($ch, CURLOPT_URL, 'https://parks.altob.com.tw/bill_service.html/proceed_bill'); // 金流
  91. curl_setopt($ch, CURLOPT_HEADER, FALSE);
  92. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  93. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  94. curl_setopt($ch, CURLOPT_POST, TRUE);
  95. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,30);
  96. curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout in seconds
  97. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($proceed_bill));
  98. $result = curl_exec($ch);
  99. if(curl_errno($ch))
  100. {
  101. trigger_error(__FUNCTION__ . ', curl error: '. curl_error($ch));
  102. }
  103. curl_close($ch);
  104. }catch (Exception $e){
  105. trigger_error(__FUNCTION__ . 'error:'.$e->getMessage());
  106. }
  107. echo $result;
  108. }
  109. /*
  110. // 買
  111. public function i_do()
  112. {
  113. $product_id = $this->uri->segment(3); // 商品代碼
  114. $data = $this->app_model()->q_coffee_shop($product_id);
  115. trigger_error(__FUNCTION__ . '..' . print_r($data, true));
  116. echo 'ok';
  117. }
  118. public function test_product_plan()
  119. {
  120. $order_no = '151246880713876';
  121. $this->app_model()->redeem_product_bill($order_no);
  122. echo 'ok';
  123. }
  124. */
  125. }