VM暫存
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123 linhas
3.2KB

  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. $this->show_page('main_page');
  20. }
  21. // 付款流程頁面 (返回)
  22. public function order_result()
  23. {
  24. $this->show_page('main_page');
  25. }
  26. // 咖啡包預覽頁
  27. public function coffee_shop()
  28. {
  29. $product_id = $this->uri->segment(3); // 商品代碼
  30. $data = $this->app_model()->q_product($product_id);
  31. unset($data['product_plan']);
  32. $this->show_page('main_page', $data);
  33. }
  34. // 付款
  35. public function transfer_money()
  36. {
  37. $product_id = $this->input->post('product_id', true);
  38. $product_code = $this->input->post('product_code', true);
  39. $invoice_receiver = $this->input->post('invoice_receiver', true);
  40. $company_no = $this->input->post('company_no', true);
  41. $email = $this->input->post('email', true);
  42. $mobile = $this->input->post('mobile', true);
  43. // 建立訂單
  44. $new_bill = $this->app_model()->create_product_bill($product_id, $product_code);
  45. if(!isset($new_bill['order_no']))
  46. {
  47. echo 'bill_create_fail';
  48. exit;
  49. }
  50. $parms = array(
  51. 'order_no' => $new_bill['order_no'],
  52. 'invoice_receiver' => $invoice_receiver,
  53. 'company_no' => $company_no,
  54. 'email' => $email,
  55. 'mobile' => $mobile
  56. );
  57. // 處理產品訂單
  58. $proceed_bill = $this->app_model()->proceed_product_bill($parms, 50); // 50: 歐付寶刷卡
  59. // 開始進行繳交帳單
  60. if(!isset($proceed_bill['status']) || $proceed_bill['status'] != 100)
  61. {
  62. echo 'bill_proceed_fail';
  63. exit;
  64. }
  65. // 串接總公司購物流程
  66. $proceed_bill['station_no'] = $this->get_station_no();
  67. $proceed_bill['product_id'] = $product_id;
  68. $proceed_bill['product_code'] = $product_code;
  69. $proceed_bill['client_back_path'] = 'shop.html/client_back';
  70. $proceed_bill['order_result_path'] = 'shop.html/order_result';
  71. trigger_error(__FUNCTION__ . '..' . print_r($proceed_bill, true));
  72. try{
  73. $ch = curl_init();
  74. curl_setopt($ch, CURLOPT_URL, 'https://parks.altob.com.tw/bill_service.html/proceed_bill'); // 金流
  75. curl_setopt($ch, CURLOPT_HEADER, FALSE);
  76. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  77. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  78. curl_setopt($ch, CURLOPT_POST, TRUE);
  79. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,30);
  80. curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout in seconds
  81. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($proceed_bill));
  82. $result = curl_exec($ch);
  83. if(curl_errno($ch))
  84. {
  85. trigger_error(__FUNCTION__ . ', curl error: '. curl_error($ch));
  86. }
  87. curl_close($ch);
  88. }catch (Exception $e){
  89. trigger_error(__FUNCTION__ . 'error:'.$e->getMessage());
  90. }
  91. echo $result;
  92. }
  93. // 買
  94. public function i_do()
  95. {
  96. $product_id = $this->uri->segment(3); // 商品代碼
  97. $data = $this->app_model()->q_coffee_shop($product_id);
  98. trigger_error(__FUNCTION__ . '..' . print_r($data, true));
  99. echo 'ok';
  100. }
  101. }