pay.class.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. abstract class Pay {
  8. public static function create($type = 'wechat', $module = '') {
  9. if($type == 'wechat') {
  10. load()->classs('pay/weixin.pay');
  11. return new WeiXinPay($module);
  12. }
  13. if($type == 'alipay') {
  14. load()->classs('pay/ali.pay');
  15. return new AliPay($module);
  16. }
  17. return null;
  18. }
  19. public function buildPayLog($params) {
  20. global $_W;
  21. if(!is_array($params) || empty($params['module']) || empty($params['tid']) || empty($params['fee']) || empty($params['type'])) {
  22. return error(-1, '参数错误');
  23. }
  24. $log = pdo_get('core_paylog', array('tid' => $params['tid'], 'uniacid' => $_W['uniacid'], 'module' => $params['tid']));
  25. if(!empty($log)) {
  26. return $log['plid'];
  27. }
  28. $moduleid = pdo_fetchcolumn("SELECT mid FROM ".tablename('modules')." WHERE name = :name", array(':name' => $params['module']));
  29. $moduleid = empty($moduleid) ? '000000' : sprintf("%06d", $moduleid);
  30. $data = array(
  31. 'uniacid' => $_W['uniacid'],
  32. 'acid' => $_W['acid'],
  33. 'openid' => $params['openid'],
  34. 'module' => $params['module'],
  35. 'fee' => $params['fee'],
  36. 'card_fee' => $params['card_fee'],
  37. 'tid' => $params['tid'],
  38. 'type' => $params['type'],
  39. 'uniontid' => date('YmdHis') . $moduleid . random(8,1),
  40. 'status' => 0,
  41. 'is_usecard' => 0,
  42. 'card_id' => 0,
  43. 'encrypt_code' => '',
  44. );
  45. pdo_insert('core_paylog', $data);
  46. return pdo_insertid();
  47. }
  48. }