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