deposit.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. $session_storage = 'session_'.pc_base::load_config('system','session_storage');
  4. pc_base::load_sys_class($session_storage);
  5. pc_base::load_app_class('foreground','member');
  6. pc_base::load_sys_class('format', '', 0);
  7. pc_base::load_sys_class('form', '', 0);
  8. pc_base::load_app_func('global');
  9. class deposit extends foreground {
  10. private $pay_db,$member_db,$account_db;
  11. function __construct() {
  12. if (!module_exists(ROUTE_M)) showmessage(L('module_not_exists'));
  13. parent::__construct();
  14. $this->pay_db = pc_base::load_model('pay_payment_model');
  15. $this->account_db = pc_base::load_model('pay_account_model');
  16. $this->_username = param::get_cookie('_username');
  17. $this->_userid = intval(param::get_cookie('_userid'));
  18. $this->handle = pc_base::load_app_class('pay_deposit');
  19. }
  20. public function init() {
  21. pc_base::load_app_class('pay_factory','',0);
  22. $where = '';
  23. $page = $_GET['page'] ? intval($_GET['page']) : '1';
  24. $where = "AND `userid` = '$this->_userid'";
  25. $start = $end = $status = '';
  26. if($_GET['dosubmit']){
  27. $start_addtime = $_GET['info']['start_addtime'];
  28. $end_addtime = $_GET['info']['end_addtime'];
  29. $status = safe_replace($_GET['info']['status']);
  30. if($start_addtime && $end_addtime) {
  31. $start = strtotime($start_addtime.' 00:00:00');
  32. $end = strtotime($end_addtime.' 23:59:59');
  33. $where .= "AND `addtime` >= '$start' AND `addtime` <= '$end'";
  34. }
  35. if($status) $where .= "AND `status` LIKE '%$status%' ";
  36. }
  37. if($where) $where = substr($where, 3);
  38. $infos = $this->account_db->listinfo($where, 'addtime DESC', $page, '15');
  39. if (is_array($infos) && !empty($infos)) {
  40. foreach($infos as $key=>$info) {
  41. if($info['status']=='unpay' && $info['pay_id']!= 0 && $info['pay_id']) {
  42. $payment = $this->handle->get_payment($info['pay_id']);
  43. $cfg = unserialize_config($payment['config']);
  44. $pay_name = ucwords($payment['pay_code']);
  45. $pay_fee = pay_fee($info['money'],$payment['pay_fee'],$payment['pay_method']);
  46. $logistics_fee = $info['logistics_fee'];
  47. $discount = $info['discount'];
  48. // calculate amount
  49. $info['price'] = $info['money'] + $pay_fee + $logistics_fee + $discount;
  50. // add order info
  51. $order_info['id'] = $info['trade_sn'];
  52. $order_info['quantity'] = $info['quantity'];
  53. $order_info['buyer_email'] = $info['email'];
  54. $order_info['order_time'] = $info['addtime'];
  55. //add product info
  56. $product_info['name'] = $info['contactname'];
  57. $product_info['body'] = $info['usernote'];
  58. $product_info['price'] = $info['price'];
  59. //add set_customerinfo
  60. $customerinfo['telephone'] = $info['telephone'];
  61. if($payment['is_online'] === '1') {
  62. $payment_handler = new pay_factory($pay_name, $cfg);
  63. $payment_handler->set_productinfo($product_info)->set_orderinfo($order_info)->set_customerinfo($customer_info);
  64. $infos[$key]['pay_btn'] = $payment_handler->get_code('value="'.L('pay_btn').'" class="pay-btn"');
  65. }
  66. } else {
  67. $infos[$key]['pay_btn'] = '';
  68. }
  69. }
  70. }
  71. foreach(L('select') as $key=>$value) {
  72. $trade_status[$key] = $value;
  73. }
  74. $pages = $this->account_db->pages;
  75. include template('pay', 'pay_list');
  76. }
  77. public function pay() {
  78. $memberinfo = $this->memberinfo;
  79. $pay_types = $this->handle->get_paytype();
  80. $trade_sn = create_sn();
  81. param::set_cookie('trade_sn',$trade_sn);
  82. $show_validator = 1;
  83. include template('pay', 'deposit');
  84. }
  85. /*
  86. * 充值方式支付
  87. */
  88. public function pay_recharge() {
  89. if(isset($_POST['dosubmit'])) {
  90. $code = isset($_POST['code']) && trim($_POST['code']) ? trim($_POST['code']) : showmessage(L('input_code'), HTTP_REFERER);
  91. if ($_SESSION['code'] != strtolower($code)) {
  92. showmessage(L('code_error'), HTTP_REFERER);
  93. }
  94. $pay_id = $_POST['pay_type'];
  95. if(!$pay_id) showmessage(L('illegal_pay_method'));
  96. $_POST['info']['name'] = safe_replace($_POST['info']['name']);
  97. $payment = $this->handle->get_payment($pay_id);
  98. $cfg = unserialize_config($payment['config']);
  99. $pay_name = ucwords($payment['pay_code']);
  100. if(!param::get_cookie('trade_sn')) {showmessage(L('illegal_creat_sn'));}
  101. $trade_sn = param::get_cookie('trade_sn');
  102. if(preg_match('![^a-zA-Z0-9/+=]!', $trade_sn)) showmessage(L('illegal_creat_sn'));
  103. $usernote = $_POST['info']['usernote'] ? $_POST['info']['name'].'['.$trade_sn.']'.'-'.new_html_special_chars(trim($_POST['info']['usernote'])) : $_POST['info']['name'].'['.$trade_sn.']';
  104. $surplus = array(
  105. 'userid' => $this->_userid,
  106. 'username' => $this->_username,
  107. 'money' => trim(floatval($_POST['info']['price'])),
  108. 'quantity' => $_POST['quantity'] ? trim(intval($_POST['quantity'])) : 1,
  109. 'telephone' => preg_match('/[^0-9\-]+/', $_POST['info']['telephone']) ? '' : trim($_POST['info']['telephone']),
  110. 'contactname' => $_POST['info']['name'] ? trim($_POST['info']['name']).L('recharge') : $this->_username.L('recharge'),
  111. 'email' => is_email($_POST['info']['email']) ? trim($_POST['info']['email']) : '',
  112. 'addtime' => SYS_TIME,
  113. 'ip' => ip(),
  114. 'pay_type' => 'recharge',
  115. 'pay_id' => $payment['pay_id'],
  116. 'payment' => trim($payment['pay_name']),
  117. 'ispay' => '1',
  118. 'usernote' => $usernote,
  119. 'trade_sn' => $trade_sn,
  120. );
  121. $recordid = $this->handle->set_record($surplus);
  122. $factory_info = $this->handle->get_record($recordid);
  123. if(!$factory_info) showmessage(L('order_closed_or_finish'));
  124. $pay_fee = pay_fee($factory_info['money'],$payment['pay_fee'],$payment['pay_method']);
  125. $logistics_fee = $factory_info['logistics_fee'];
  126. $discount = $factory_info['discount'];
  127. // calculate amount
  128. $factory_info['price'] = $factory_info['money'] + $pay_fee + $logistics_fee + $discount;
  129. // add order info
  130. $order_info['id'] = $factory_info['trade_sn'];
  131. $order_info['quantity'] = $factory_info['quantity'];
  132. $order_info['buyer_email'] = $factory_info['email'];
  133. $order_info['order_time'] = $factory_info['addtime'];
  134. //add product info
  135. $product_info['name'] = $factory_info['contactname'];
  136. $product_info['body'] = $factory_info['usernote'];
  137. $product_info['price'] = $factory_info['price'];
  138. //add set_customerinfo
  139. $customerinfo['telephone'] = $factory_info['telephone'];
  140. if($payment['is_online'] === '1') {
  141. pc_base::load_app_class('pay_factory','',0);
  142. $payment_handler = new pay_factory($pay_name, $cfg);
  143. $payment_handler->set_productinfo($product_info)->set_orderinfo($order_info)->set_customerinfo($customer_info);
  144. $code = $payment_handler->get_code('value="'.L('confirm_pay').'" class="button"');
  145. } else {
  146. $this->account_db->update(array('status'=>'waitting','pay_type'=>'offline'),array('id'=>$recordid));
  147. $code = '<div class="point">'.L('pay_tip').'</div>';
  148. }
  149. }
  150. include template('pay', 'payment_cofirm');
  151. }
  152. public function public_checkcode() {
  153. $code = $_GET['code'];
  154. if($_SESSION['code'] != strtolower($code)) {
  155. exit('0');
  156. } else {
  157. exit('1');
  158. }
  159. }
  160. }
  161. ?>