更新支付
This commit is contained in:
parent
c61ed58c4a
commit
a9da43c26c
|
|
@ -55,4 +55,4 @@ class ApiController extends BaseController
|
||||||
{
|
{
|
||||||
return $this->ignoreAction;
|
return $this->ignoreAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use app\common\models\Protocol;
|
||||||
use app\common\services\Session;
|
use app\common\services\Session;
|
||||||
use app\frontend\models\MemberShopInfo;
|
use app\frontend\models\MemberShopInfo;
|
||||||
use app\frontend\modules\member\services\factory\MemberFactory;
|
use app\frontend\modules\member\services\factory\MemberFactory;
|
||||||
|
use app\frontend\modules\member\services\MemberOfficeAccountService;
|
||||||
use app\frontend\modules\member\services\MemberService;
|
use app\frontend\modules\member\services\MemberService;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
|
|
||||||
|
|
@ -33,15 +34,17 @@ class LoginController extends ApiController
|
||||||
|
|
||||||
$uniacid = \YunShop::app()->uniacid;
|
$uniacid = \YunShop::app()->uniacid;
|
||||||
$mid = Member::getMid();
|
$mid = Member::getMid();
|
||||||
|
|
||||||
//判断是否开启微信登录
|
//判断是否开启微信登录
|
||||||
if (\YunShop::request()->show_wechat_login) {
|
if (\YunShop::request()->show_wechat_login) {
|
||||||
return $this->init_login();
|
return $this->init_login();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request()->input('iscode') == 1 || request()->input('code')!=1) {
|
||||||
|
$className = new MemberOfficeAccountService();
|
||||||
|
$className->getWechatOpenid();
|
||||||
|
}
|
||||||
if (!empty($type)) {
|
if (!empty($type)) {
|
||||||
$member = MemberFactory::create($type);
|
$member = MemberFactory::create($type);
|
||||||
|
|
||||||
if ($member !== null) {
|
if ($member !== null) {
|
||||||
$msg = $member->login();
|
$msg = $member->login();
|
||||||
|
|
||||||
|
|
@ -231,6 +234,7 @@ class LoginController extends ApiController
|
||||||
$data['title2'] = $registerSet['title2'] ? : '登录尽享各种优惠权益!';
|
$data['title2'] = $registerSet['title2'] ? : '登录尽享各种优惠权益!';
|
||||||
$data['login_page_mode'] = $registerSet['login_page_mode'] ? : 0;
|
$data['login_page_mode'] = $registerSet['login_page_mode'] ? : 0;
|
||||||
$data['login_banner_url'] = $registerSet['login_banner'] ? yz_tomedia($registerSet['login_banner']): '';
|
$data['login_banner_url'] = $registerSet['login_banner'] ? yz_tomedia($registerSet['login_banner']): '';
|
||||||
|
|
||||||
$data['login_diy_url'] = $registerSet['login_diy_url'] ? : '';
|
$data['login_diy_url'] = $registerSet['login_diy_url'] ? : '';
|
||||||
$registerSet['login_mode'] || $registerSet['login_mode'] = [];
|
$registerSet['login_mode'] || $registerSet['login_mode'] = [];
|
||||||
$data['mobile_code_login'] = !$registerSet['login_mode'] || in_array('mobile_code',$registerSet['login_mode']) ? 1 : 0;//开启手机验证码登录
|
$data['mobile_code_login'] = !$registerSet['login_mode'] || in_array('mobile_code',$registerSet['login_mode']) ? 1 : 0;//开启手机验证码登录
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* Author:
|
* Author:
|
||||||
* Date: 17/2/22
|
* Date: 17/2/22
|
||||||
* Time: 下午4:44
|
* Time: 下午4:44
|
||||||
*/
|
*/
|
||||||
|
|
@ -73,20 +73,49 @@ class MemberOfficeAccountService extends MemberService
|
||||||
$member_id = $this->memberLogin($userinfo);
|
$member_id = $this->memberLogin($userinfo);
|
||||||
|
|
||||||
if($member_id) event(new \app\common\events\member\MemberLoginEvent($member_id));
|
if($member_id) event(new \app\common\events\member\MemberLoginEvent($member_id));
|
||||||
|
|
||||||
Session::set('member_id', $member_id);
|
Session::set('member_id', $member_id);
|
||||||
setcookie('Yz-Token', encrypt($userinfo['access_token'] . '\t' . ($userinfo['expires_in'] + time()) . '\t' . $userinfo['openid'] . '\t' . $scope), time() + self::TOKEN_EXPIRE);
|
setcookie('Yz-Token', encrypt($userinfo['access_token'] . '\t' . ($userinfo['expires_in'] + time()) . '\t' . $userinfo['openid'] . '\t' . $scope), time() + self::TOKEN_EXPIRE);
|
||||||
} else {
|
} else {
|
||||||
$this->_setClientRequestUrl();
|
$this->_setClientRequestUrl();
|
||||||
$oauth->redirect()->send();
|
$oauth->redirect()->send();
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect($this->_getClientRequestUrl())->send();
|
redirect($this->_getClientRequestUrl())->send();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getWechatOpenid()
|
||||||
|
{
|
||||||
|
$uniacid = \YunShop::app()->uniacid;
|
||||||
|
$code = \YunShop::request()->code;
|
||||||
|
$account = AccountWechats::getAccountByUniacid($uniacid);
|
||||||
|
$appId = $account->key;
|
||||||
|
$appSecret = $account->secret;
|
||||||
|
$state = 'yz-' . session_id();
|
||||||
|
$callback = ($_SERVER['REQUEST_SCHEME'] ? $_SERVER['REQUEST_SCHEME'] : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||||
|
$authurl = $this->_getAuthBaseUrl($appId, $callback, $state);
|
||||||
|
$tokenurl = $this->_getTokenUrl($appId, $appSecret, $code);
|
||||||
|
if (!empty($code)) {
|
||||||
|
$redirect_url = base64_decode(\YunShop::request()->page).'&code=1';
|
||||||
|
$token = \Curl::to($tokenurl)
|
||||||
|
->asJsonResponse(true)
|
||||||
|
->get();
|
||||||
|
if (!empty($token) && !empty($token['errmsg']) && $token['errmsg'] == 'invalid code') {
|
||||||
|
return show_json(5, 'token请求错误');
|
||||||
|
}
|
||||||
|
$userinfo = $this->getUserInfo($appId, $appSecret, $token);
|
||||||
|
if (is_array($userinfo) && !empty($userinfo['errcode'])) {
|
||||||
|
\Log::debug('微信登陆授权失败-' . $userinfo['errcode']);
|
||||||
|
return show_json(-3, '微信登陆授权失败');
|
||||||
|
}
|
||||||
|
Session::set('wx_open_id', $token['openid']);
|
||||||
|
redirect($redirect_url)->send();
|
||||||
|
} else {
|
||||||
|
redirect($authurl)->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace BsPaySdk\core;
|
namespace BsPaySdk\core;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
@ -24,7 +25,8 @@ class BsPayClient extends BsPay
|
||||||
* boolean $tag true (页面接口请求) | false (非页面接口请求)
|
* boolean $tag true (页面接口请求) | false (非页面接口请求)
|
||||||
* CURLFile $tag 待上传的文件
|
* CURLFile $tag 待上传的文件
|
||||||
*/
|
*/
|
||||||
public function postRequest($request, $tag = false) {
|
public function postRequest($request, $tag = false)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
// 请求接口获取应答
|
// 请求接口获取应答
|
||||||
if (is_object($request)) {
|
if (is_object($request)) {
|
||||||
|
|
@ -32,20 +34,17 @@ class BsPayClient extends BsPay
|
||||||
} else {
|
} else {
|
||||||
$data = $request;
|
$data = $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理文件上传接口
|
// 处理文件上传接口
|
||||||
if (is_object($tag)) {
|
if (is_object($tag)) {
|
||||||
$data['params']['needSign'] = false; // 请求不加签名
|
$data['params']['needSign'] = false; // 请求不加签名
|
||||||
$data['params']['needVerfySign'] = false; // 返回数据不验证签名
|
$data['params']['needVerfySign'] = false; // 返回数据不验证签名
|
||||||
return self::post($data['funcCode'], $data['params'], $tag, $this->merChantKey);
|
return self::post($data['funcCode'], $data['params'], $tag, $this->merChantKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理页面接口请求
|
// 处理页面接口请求
|
||||||
if ($tag) {
|
if ($tag) {
|
||||||
$data['params']['needSign'] = true; // 请求加签名
|
$data['params']['needSign'] = true; // 请求加签名
|
||||||
$data['params']['needVerfySign'] = false; // 返回数据不验证签名
|
$data['params']['needVerfySign'] = false; // 返回数据不验证签名
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::post($data['funcCode'], $data['params'], "", $this->merChantKey);
|
return self::post($data['funcCode'], $data['params'], "", $this->merChantKey);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e->getMessage();
|
echo $e->getMessage();
|
||||||
|
|
@ -55,9 +54,10 @@ class BsPayClient extends BsPay
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对象转换数组
|
* 对象转换数组
|
||||||
* @param object $object 待转化参数对象
|
* @param object $object 待转化参数对象
|
||||||
*/
|
*/
|
||||||
public function objectToArray($object) {
|
public function objectToArray($object)
|
||||||
|
{
|
||||||
$class = new ReflectionClass($object);
|
$class = new ReflectionClass($object);
|
||||||
$properties = $class->getProperties();
|
$properties = $class->getProperties();
|
||||||
$arrayData = array();
|
$arrayData = array();
|
||||||
|
|
@ -66,8 +66,8 @@ class BsPayClient extends BsPay
|
||||||
// 转换接口参数
|
// 转换接口参数
|
||||||
foreach ($properties as $key => $value) {
|
foreach ($properties as $key => $value) {
|
||||||
$attrName = $value->getName();
|
$attrName = $value->getName();
|
||||||
$method = 'get'.ucfirst($attrName);
|
$method = 'get' . ucfirst($attrName);
|
||||||
if ( $class->hasMethod($method) ) {
|
if ($class->hasMethod($method)) {
|
||||||
$attrValue = $class->getMethod($method)->invoke($object);
|
$attrValue = $class->getMethod($method)->invoke($object);
|
||||||
if (isset($attrValue)) {
|
if (isset($attrValue)) {
|
||||||
if ($attrName != "extendInfos") {
|
if ($attrName != "extendInfos") {
|
||||||
|
|
@ -91,4 +91,4 @@ class BsPayClient extends BsPay
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use app\common\helpers\Url;
|
||||||
use app\common\models\Member;
|
use app\common\models\Member;
|
||||||
use app\common\models\PayOrder;
|
use app\common\models\PayOrder;
|
||||||
use app\common\services\Pay;
|
use app\common\services\Pay;
|
||||||
|
use app\common\services\Session;
|
||||||
use BsPaySdk\core\BsPay;
|
use BsPaySdk\core\BsPay;
|
||||||
use BsPaySdk\core\BsPayClient;
|
use BsPaySdk\core\BsPayClient;
|
||||||
use BsPaySdk\request\V2TradePaymentJspayRequest;
|
use BsPaySdk\request\V2TradePaymentJspayRequest;
|
||||||
|
|
@ -80,6 +81,7 @@ class HfPay extends Pay
|
||||||
$op = "{$this->payTpye[$this->TradeType]}订单支付 订单号:" . $data['order_no'];
|
$op = "{$this->payTpye[$this->TradeType]}订单支付 订单号:" . $data['order_no'];
|
||||||
$this->log($data['extra']['type'], $this->payTpye[$this->TradeType], $data['amount'], $op, $data['order_no'], Pay::ORDER_STATUS_NON, \YunShop::app()->getMemberId());
|
$this->log($data['extra']['type'], $this->payTpye[$this->TradeType], $data['amount'], $op, $data['order_no'], Pay::ORDER_STATUS_NON, \YunShop::app()->getMemberId());
|
||||||
|
|
||||||
|
|
||||||
$this->notify_url = Url::shopSchemeUrl('payment/hfpay/notifyUrl.php');
|
$this->notify_url = Url::shopSchemeUrl('payment/hfpay/notifyUrl.php');
|
||||||
// 2.组装请求参数
|
// 2.组装请求参数
|
||||||
$request = new V2TradePaymentJspayRequest();
|
$request = new V2TradePaymentJspayRequest();
|
||||||
|
|
@ -166,7 +168,7 @@ class HfPay extends Pay
|
||||||
case 'T_H5':
|
case 'T_H5':
|
||||||
$openid = Member::getOpenIdForType(\YunShop::app()->getMemberId());
|
$openid = Member::getOpenIdForType(\YunShop::app()->getMemberId());
|
||||||
$data['wx_data'] = [
|
$data['wx_data'] = [
|
||||||
'openid' => $openid
|
'openid' => $openid?: Session::get('wx_open_id')
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'A_JSAPI':
|
case 'A_JSAPI':
|
||||||
|
|
@ -202,4 +204,4 @@ class HfPay extends Pay
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue