微擎$this->pay()和退款方法所在文件
/framework/class/account/account.class.php代码片段:
protected function pay($params = array(), $mine = array()) {
global $_W;
load()->model('activity');
load()->model('module');
activity_coupon_type_init();
if(!$this->inMobile) {
message('支付功能只能在手机上使用', '', '');
}
$params['module'] = $this->module['name'];
if($params['fee'] <= 0) {
$pars = array();
$pars['from'] = 'return';
$pars['result'] = 'success';
$pars['type'] = '';
$pars['tid'] = $params['tid'];
$site = WeUtility::createModuleSite($params['module']);
$method = 'payResult';
if (method_exists($site, $method)) {
exit($site->$method($pars));
}
}
$log = pdo_get('core_paylog', array('uniacid' => $_W['uniacid'], 'module' => $params['module'], 'tid' => $params['tid']));
if (empty($log)) {
$log = array(
'uniacid' => $_W['uniacid'],
'acid' => $_W['acid'],
'openid' => $_W['member']['uid'],
'module' => $this->module['name'],
'tid' => $params['tid'],
'fee' => $params['fee'],
'card_fee' => $params['fee'],
'status' => '0',
'is_usecard' => '0',
);
pdo_insert('core_paylog', $log);
}
if($log['status'] == '1') {
message('这个sdsfsdf订单已经支付成功, 不需要重复支付.', '', 'info');
}
$setting = uni_setting($_W['uniacid'], array('payment', 'creditbehaviors'));
if(!is_array($setting['payment'])) {
message('没有有效的支付方式, 请联系网站管理员.', '', 'error');
}
$pay = $setting['payment'];
$we7_coupon_info = module_fetch('we7_coupon');
if (!empty($we7_coupon_info)) {
$cards = activity_paycenter_coupon_available();
if (!empty($cards)) {
foreach ($cards as $key => &$val) {
if ($val['type'] == '1') {
$val['discount_cn'] = sprintf("%.2f", $params['fee'] * (1 - $val['extra']['discount'] * 0.01));
$coupon[$key] = $val;
} else {
$val['discount_cn'] = sprintf("%.2f", $val['extra']['reduce_cost'] * 0.01);
$token[$key] = $val;
if ($log['fee'] < $val['extra']['least_cost'] * 0.01) {
unset($token[$key]);
}
}
unset($val['icon']);
unset($val['description']);
}
}
$cards_str = json_encode($cards);
}
foreach ($pay as &$value) {
$value['switch'] = $value['pay_switch'];
}
unset($value);
if (empty($_W['member']['uid'])) {
$pay['credit']['switch'] = false;
}
if ($params['module'] == 'paycenter') {
$pay['delivery']['switch'] = false;
$pay['line']['switch'] = false;
}
if (!empty($pay['credit']['switch'])) {
$credtis = mc_credit_fetch($_W['member']['uid']);
$credit_pay_setting = mc_fetch($_W['member']['uid'], array('pay_password'));
$credit_pay_setting = $credit_pay_setting['pay_password'];
}
$you = 0;
include $this->template('common/paycenter');
}退款和支付验证代码片段:
protected function refund($tid, $fee = 0, $reason = '') {
load()->model('refund');
$refund_id = refund_create_order($tid, $this->module['name'], $fee, $reason);
if (is_error($refund_id)) {
return $refund_id;
}
return refund($refund_id);
}
public function payResult($ret) {
global $_W;
if($ret['from'] == 'return') {
if ($ret['type'] == 'credit2') {
message('已经成功支付', url('mobile/channel', array('name' => 'index', 'weid' => $_W['weid'])), 'success');
} else {
message('已经成功支付', '../../' . url('mobile/channel', array('name' => 'index', 'weid' => $_W['weid'])), 'success');
}
}
}
页:
[1]