scanpay.inc.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. defined('IN_IA') or exit('Access Denied');
  3. global $_W, $_GPC;
  4. paycenter_check_login();
  5. $user_permission = permission_account_user('system');
  6. $op = trim($_GPC['op']) ? trim($_GPC['op']) : 'index';
  7. if ($_W['account']['level'] != ACCOUNT_SERVICE_VERIFY) {
  8. message('公众号权限不足', '', 'error');
  9. }
  10. if($op == 'post') {
  11. if(checksubmit()) {
  12. $fee = trim($_GPC['fee']) ? trim($_GPC['fee']) : message('收款金额有误', '', 'error');
  13. $body = trim($_GPC['body']) ? trim($_GPC['body']) : '收银台收款' . $fee;
  14. $data = array(
  15. 'uniacid' => $_W['uniacid'],
  16. 'clerk_id' => $_W['user']['clerk_id'],
  17. 'clerk_type' => $_W['user']['clerk_type'],
  18. 'store_id' => $_W['user']['store_id'],
  19. 'body' => $body,
  20. 'fee' => $fee,
  21. 'final_fee' => $fee,
  22. 'credit_status' => 1,
  23. 'createtime' => TIMESTAMP,
  24. );
  25. pdo_insert('paycenter_order', $data);
  26. $id = pdo_insertid();
  27. header('location:' . $this->createMobileUrl('scanpay', array('op' => 'qrcode', 'id' => $id)));
  28. die;
  29. }
  30. }
  31. if($op == 'qrcode') {
  32. $id = intval($_GPC['id']);
  33. $order = pdo_get('paycenter_order', array('uniacid' => $_W['uniacid'], 'id' => $id));
  34. if(empty($order)) {
  35. message('订单不存在或已删除', '', 'error');
  36. }
  37. if($order['status'] == 1) {
  38. message('该订单已付款', '', 'error');
  39. }
  40. }
  41. if($op == 'list') {
  42. $condition = ' WHERE uniacid = :uniacid AND status = 1 AND clerk_id = :clerk_id ';
  43. $params = array(':uniacid' => $_W['uniacid'], ':clerk_id' => $_W['user']['clerk_id']);
  44. $period = intval($_GPC['period']);
  45. if($period <= 0) {
  46. $starttime = strtotime(date('Y-m-d')) + $period * 86400;
  47. $endtime = $starttime + 86400;
  48. $condition .= ' AND paytime >= :starttime AND paytime <= :endtime ';
  49. $params[':starttime'] = $starttime;
  50. $params[':endtime'] = $endtime;
  51. }
  52. $orders = pdo_fetchall('SELECT * FROM ' . tablename('paycenter_order') . $condition . ' ORDER BY paytime DESC ', $params);
  53. }
  54. if($op == 'detail') {
  55. $id = intval($_GPC['id']);
  56. $order = pdo_get('paycenter_order', array('uniacid' => $_W['uniacid'], 'id' => $id));
  57. if(empty($order)) {
  58. message('订单不存在', '', '');
  59. } else {
  60. $store_id = $order['store_id'];
  61. $types = paycenter_order_types();
  62. $trade_types = paycenter_order_trade_types();
  63. $status = paycenter_order_status();
  64. $store_info = pdo_get('activity_stores', array('id' => $store_id), array('business_name'));
  65. }
  66. }
  67. include $this->template('scanpay');