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 2.9KB

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