查看: 754|回复: 0

微擎$this->pay()和退款方法所在文件

[复制链接]

748

主题

39

回帖

3907

积分

管理员

总舵主

积分
3907
QQ
发表于 2024-5-25 20:12:05 | 显示全部楼层 |阅读模式
/framework/class/account/account.class.php
代码片段:
  1. protected function pay($params = array(), $mine = array()) {
  2.                 global $_W;
  3.                 load()->model('activity');
  4.                 load()->model('module');
  5.                 activity_coupon_type_init();
  6.                 if(!$this->inMobile) {
  7.                         message('支付功能只能在手机上使用', '', '');
  8.                 }
  9.                 $params['module'] = $this->module['name'];
  10.                 if($params['fee'] <= 0) {
  11.                         $pars = array();
  12.                         $pars['from'] = 'return';
  13.                         $pars['result'] = 'success';
  14.                         $pars['type'] = '';
  15.                         $pars['tid'] = $params['tid'];
  16.                         $site = WeUtility::createModuleSite($params['module']);
  17.                         $method = 'payResult';
  18.                         if (method_exists($site, $method)) {
  19.                                 exit($site->$method($pars));
  20.                         }
  21.                 }
  22.                 $log = pdo_get('core_paylog', array('uniacid' => $_W['uniacid'], 'module' => $params['module'], 'tid' => $params['tid']));
  23.                 if (empty($log)) {
  24.                         $log = array(
  25.                                 'uniacid' => $_W['uniacid'],
  26.                                 'acid' => $_W['acid'],
  27.                                 'openid' => $_W['member']['uid'],
  28.                                 'module' => $this->module['name'],
  29.                                 'tid' => $params['tid'],
  30.                                 'fee' => $params['fee'],
  31.                                 'card_fee' => $params['fee'],
  32.                                 'status' => '0',
  33.                                 'is_usecard' => '0',
  34.                         );
  35.                         pdo_insert('core_paylog', $log);
  36.                 }
  37.                 if($log['status'] == '1') {
  38.                         message('这个sdsfsdf订单已经支付成功, 不需要重复支付.', '', 'info');
  39.                 }
  40.                 $setting = uni_setting($_W['uniacid'], array('payment', 'creditbehaviors'));
  41.                 if(!is_array($setting['payment'])) {
  42.                         message('没有有效的支付方式, 请联系网站管理员.', '', 'error');
  43.                 }
  44.                 $pay = $setting['payment'];
  45.                 $we7_coupon_info = module_fetch('we7_coupon');
  46.                 if (!empty($we7_coupon_info)) {
  47.                         $cards = activity_paycenter_coupon_available();
  48.                         if (!empty($cards)) {
  49.                                 foreach ($cards as $key => &$val) {
  50.                                         if ($val['type'] == '1') {
  51.                                                 $val['discount_cn'] = sprintf("%.2f", $params['fee'] * (1 - $val['extra']['discount'] * 0.01));
  52.                                                 $coupon[$key] = $val;
  53.                                         } else {
  54.                                                 $val['discount_cn'] = sprintf("%.2f", $val['extra']['reduce_cost'] * 0.01);
  55.                                                 $token[$key] = $val;
  56.                                                 if ($log['fee'] < $val['extra']['least_cost'] * 0.01) {
  57.                                                         unset($token[$key]);
  58.                                                 }
  59.                                         }
  60.                                         unset($val['icon']);
  61.                                         unset($val['description']);
  62.                                 }
  63.                         }
  64.                         $cards_str = json_encode($cards);
  65.                 }
  66.                 foreach ($pay as &$value) {
  67.                         $value['switch'] = $value['pay_switch'];
  68.                 }
  69.                 unset($value);
  70.                 if (empty($_W['member']['uid'])) {
  71.                         $pay['credit']['switch'] = false;
  72.                 }
  73.                 if ($params['module'] == 'paycenter') {
  74.                         $pay['delivery']['switch'] = false;
  75.                         $pay['line']['switch'] = false;
  76.                 }
  77.                 if (!empty($pay['credit']['switch'])) {
  78.                         $credtis = mc_credit_fetch($_W['member']['uid']);
  79.                         $credit_pay_setting = mc_fetch($_W['member']['uid'], array('pay_password'));
  80.                         $credit_pay_setting = $credit_pay_setting['pay_password'];
  81.                 }
  82.                 $you = 0;
  83.                 include $this->template('common/paycenter');
  84.         }
复制代码
退款和支付验证代码片段:
  1. protected function refund($tid, $fee = 0, $reason = '') {
  2.                 load()->model('refund');
  3.                 $refund_id = refund_create_order($tid, $this->module['name'], $fee, $reason);
  4.                 if (is_error($refund_id)) {
  5.                         return $refund_id;
  6.                 }
  7.                 return refund($refund_id);
  8.         }

  9.       
  10.         public function payResult($ret) {
  11.                 global $_W;
  12.                 if($ret['from'] == 'return') {
  13.                         if ($ret['type'] == 'credit2') {
  14.                                 message('已经成功支付', url('mobile/channel', array('name' => 'index', 'weid' => $_W['weid'])), 'success');
  15.                         } else {
  16.                                 message('已经成功支付', '../../' . url('mobile/channel', array('name' => 'index', 'weid' => $_W['weid'])), 'success');
  17.                         }
  18.                 }
  19.         }
复制代码


道不同,不相为谋!理想要有,万一实现了呢?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:2513533699@qq.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|鲁ICP备19000917号|鲁公网安备37078302000320号

在本版发帖
关注公众号
QQ客服返回顶部