* @version : HUOSDK 8.0 */ namespace web\pc\controller\v8; use think\Session; use web\common\controller\WebBaseController; use web\pc\logic\PayLogic; class PayController extends WebBaseController { private function setorderid($mem_id) { list($usec, $sec) = explode(" ", microtime()); // 取微秒前3位+再两位随机数+渠道ID后四位 $orderid = $sec.substr($usec, 2, 3).rand(10, 99).sprintf("%04d", $mem_id % 10000); return $orderid; } /** * 充值平台币下单操作 * @return array|mixed */ public function doPay() { $_class = new PayLogic(); $type = request()->param('type','alipay'); $ptb_cnt = request()->param('amount'); // 获取平台币数量 $username = request()->param('username'); if(empty($type) || empty($ptb_cnt) || empty($username)) { $this->error('参数错误'); } switch ($type) { case 'alipay' : // 支付宝 $_res = $_class->_alipayweb(); if (isset($_res['error']) && $_res['error'] > 0) { $this->error($_res['msg']); } break; case 'spay' : // 微信支付 $_res = $_class->_spayweb(); if (isset($_res['status']) && $_res['status'] == 1) { $this->assign($_res['data']); return $this->fetch('Pay/spay'); } else { $this->error('支付失败'); } break; default : return array('error' => 2, 'msg' => '请选择正确的支付方式'); } } /** * 平台币支付宝充值回调 */ public function ptb_alipay_notify() { $_class = new PayLogic(); $_class->alipay_notify(); } /** * 平台币威富通充值回调 */ public function ptb_spay_notify() { $_class = new PayLogic(); $_class->spay_notify(); } /** * 威富通充值状态查询 * @return array */ public function spay_status(){ $_order_id = $this->request->param('order_id'); $_class = new PayLogic(); return $_class->spayStatus($_order_id); } }