wangmingchuan 11 months ago
parent b4e4475dbf
commit 98b0fe617a
  1. 6
      application/config.php
  2. 6
      application/database.php
  3. 16
      application/wap/controller/AuthController.php
  4. 2
      application/wap/controller/Login.php
  5. 42
      extend/basic/WapBasic.php
  6. 13
      extend/service/MiniProgramService.php
  7. 1
      vendor/overtrue/wechat/src/MiniProgram/Sns/Sns.php

@ -274,21 +274,21 @@ return [
//监听ip
'ip' => '0.0.0.0',
//监听端口
'port' => '20014'
'port' => '20016'
],
//内部通讯
'channel' => [
//通讯ip
'ip' => '127.0.0.1',
//通讯端口
'port' => '20015'
'port' => '20017'
],
//Register
'text' => [
//通讯ip
'ip' => '0.0.0.0',
//通讯端口
'port' => '20015'
'port' => '20017'
],
],

@ -15,11 +15,11 @@ return [
// 服务器地址
'hostname' => 'localhost',
// 数据库名
'database' => 'knowledge',
'database' => 'knowledge_pmt',
// 用户名
'username' => 'knowledge',
'username' => 'knowledge_pmt',
// 密码
'password' => 'D7R84pxct8KscHmx',
'password' => 'qq111111',
// 端口
'hostport' => '3306',

@ -33,7 +33,7 @@ use app\institution\model\institution\InstitutionAdmin;
use app\admin\model\special\Lecturer;
class AuthController extends WapBasic
class AuthController extends WapBasic
{
/**
* 用户ID
@ -79,11 +79,6 @@ class AuthController extends WapBasic
$this->subjectUrl = getUrlToDomain();
$this->site_url = $site_url;
if ($isNextVersion) {
$jwtService = new JwtService();
try {
@ -106,6 +101,7 @@ class AuthController extends WapBasic
$this->uid = $this->userInfo['uid'];
$this->phone = User::getLogPhone($uid);
//绑定推广人
if ($spread_uid && $spreadUserInfo && $this->uid != $spread_uid && $spreadUserInfo['spread_uid'] != $this->uid && $this->userInfo['spread_uid'] != $spread_uid && !$this->userInfo['spread_uid']) {
$storeBrokerageStatu = SystemConfigService::get('store_brokerage_statu') ?: 1; //获取后台分销类型
if ($storeBrokerageStatu == 1) {
@ -131,7 +127,7 @@ class AuthController extends WapBasic
} catch (Exception $e) {
if ($NoWechantVisitWhite) {
$msg = $e->getMessage();
return JsonService::fail($msg ? $msg : '请登录再进行访问!');
}
@ -188,16 +184,18 @@ class AuthController extends WapBasic
if ($this->request->isAjax())
return JsonService::fail('请登录再进行访问');
else
return $this->redirect(Url::build('Login/index', ['spread_uid' => $spread_uid]) . '?ref=' . base64_encode(htmlspecialchars($url)));
}
}
}
$institutionInfo = InstitutionAdmin::where('uid',$this->userInfo['uid'])->value('mer_id');
$institution = Lecturer::where(array('agent'=>$institutionInfo,'is_del' => 0))->select()->toArray();
$institution_exp = implode(',',array_column($institution,'mer_id'));
$this->institution = $institution_exp ? $institution_exp . ',' .$institutionInfo : $institutionInfo;
if (Cache::has('__SYSTEM__')) {
$overallShareWechat = Cache::get('__SYSTEM__');
} else {

@ -81,7 +81,7 @@ class Login extends WapBasic
throw new ValidateException('登录失败');
}
}
/*
/*
小程序APP授权登录
*/
public function routine_auth(Request $request)

@ -100,7 +100,7 @@ class WapBasic extends Controller
return $this->failed('请设置redis密码!', 'http://help.crmeb.net/crmeb_zsff/1907223');
}
}
protected function oauth($spread_uid = 0, $is_h5 = false)
{ /* exit($this->failed('微信用户信息获取失败!!')); */
$openid = Session::get('loginOpenid', 'wap');
@ -109,7 +109,7 @@ class WapBasic extends Controller
if (!UtilService::isWechatBrowser()) exit($this->failed('请在微信客户端打开链接'));
//if ($this->request->isAjax()) exit($this->failed('请登陆!'));
$errorNum = (int)Cookie::get('_oen');
if ($errorNum && $errorNum > 3) exit($this->failed('微信用户信息获取失败!!'));
if ($errorNum && $errorNum > 3) exit($this->failed('微信用户信息获取失败!!'));
try {
$original = WechatService::oauthService()->getAccessToken($this->request->get('code'));
if (!WechatUser::be(['openid' => $original->openid]) && $original->scope === 'snsapi_base') {
@ -157,7 +157,7 @@ class WapBasic extends Controller
}else{
return UserBehavior::wechatOauthAfter($openid, $wechatInfo,true);
}
}
/**
* APP微信授权登录
@ -199,7 +199,7 @@ class WapBasic extends Controller
}
$tokenService = new JwtService();
$token['token'] = $tokenService->getToken((int)$user['uid']);
if ($token) {
/** @var UserVisitServices $visitServices */
/* $visitServices = app()->make(UserVisitServices::class);
@ -211,7 +211,7 @@ class WapBasic extends Controller
} catch (\Throwable $th) {
return $th->getMessage();
}
}
@ -300,12 +300,12 @@ class WapBasic extends Controller
'nickname' => $username
]);
}
$wechatUserServices->wechatUpdata([$user['uid'], $createData[1]]);
}
$tokenService = new JwtService();
$token['token'] = $tokenService->getToken((int)$user['uid']);
if ($token) {
/** @var UserVisitServices $visitServices */
/* $visitServices = app()->make(UserVisitServices::class);
@ -317,7 +317,7 @@ class WapBasic extends Controller
} catch (\Throwable $th) {
return $th->getMessage();
}
}
@ -347,7 +347,7 @@ class WapBasic extends Controller
if (!isset($userInfoCong['open_id'])) {
throw new ValidateException('openid获取失败');
}
try {
//解密获取用户信息
$userInfo = KuaiMiniProgramService::encryptor($session_key, $iv, $encryptedData);
@ -355,7 +355,7 @@ class WapBasic extends Controller
if ($e->getCode() == '-41003') {
throw new ValidateException('获取会话密匙失败');
}
}
}
$userInfo['unionId'] = isset($userInfoCong['unionid']) ? $userInfoCong['unionid'] : '';
$userInfo['openId'] = $openid = $userInfoCong['open_id'];
$userInfo['spid'] = $spid;
@ -373,15 +373,15 @@ class WapBasic extends Controller
// 新用户获取后台默认名称
$createData['nickname'] =$userInfo['nickName'];
$createData[1]['nickname'] = $userInfo['nickName'];
$user = $wechatUserServices->wechatOauthAfter($createData);
$user = $wechatUserServices->wechatOauthAfter($createData);
} else {
//更新用户信息
$wechatUserServices->wechatUpdata([$user['uid'], $createData[1]]);
}
$tokenService = new JwtService();
$token['token'] = $tokenService->getToken((int)$user['uid']);
if ($token) {
$token['userInfo'] = User::where('uid', $user['uid'])->find();
return $token;
@ -390,10 +390,10 @@ class WapBasic extends Controller
} catch (\Throwable $th) {
return $th->getMessage();
}
}
/**
* 抖音头条小程序授权登录
* @param $code
@ -420,7 +420,7 @@ class WapBasic extends Controller
if (!isset($userInfoCong['openid'])) {
throw new ValidateException('openid获取失败');
}
try {
//解密获取用户信息
$userInfo = TouMiniProgramService::encryptor($session_key, $iv, $encryptedData);
@ -428,7 +428,7 @@ class WapBasic extends Controller
if ($e->getCode() == '-41003') {
throw new ValidateException('获取会话密匙失败');
}
}
}
$userInfo['unionId'] = isset($userInfoCong['unionid']) ? $userInfoCong['unionid'] : '';
$userInfo['openId'] = $openid = $userInfoCong['openid'];
$userInfo['spid'] = $spid;
@ -446,15 +446,15 @@ class WapBasic extends Controller
// 新用户获取后台默认名称
$createData['nickname'] =$userInfo['nickName'];
$createData[1]['nickname'] = $userInfo['nickName'];
$user = $toutiaoUser->wechatOauthAfter($createData);
$user = $toutiaoUser->wechatOauthAfter($createData);
} else {
//更新用户信息
$toutiaoUser->wechatUpdata([$user['uid'], $createData[1]]);
}
$tokenService = new JwtService();
$token['token'] = $tokenService->getToken((int)$user['uid']);
if ($token) {
$token['userInfo'] = User::where('uid', $user['uid'])->find();
return $token;
@ -463,7 +463,7 @@ class WapBasic extends Controller
} catch (\Throwable $th) {
return $th->getMessage();
}
}
/**
* 小程序创建用户后返回uid

@ -72,7 +72,7 @@ class MiniProgramService
protected static $instance;
public static function options()
{
{
$wechat = SystemConfigService::more(['wechat_app_appsecret', 'wechat_app_appid', 'site_url', 'mini_appid', 'mini_secret']);
$payment = SystemConfigService::more(['pay_weixin_mchid', 'pay_weixin_client_cert', 'pay_weixin_client_key', 'pay_weixin_key', 'pay_weixin_open']);
$config = [];
@ -83,6 +83,7 @@ class MiniProgramService
$appId = isset($wechat['mini_appid']) ? trim($wechat['mini_appid']) : '';
$appsecret = isset($wechat['mini_secret']) ? trim($wechat['mini_secret']) : '';
//}
$config['mini_program'] = [
'app_id' => $appId,
'secret' => $appsecret,
@ -186,7 +187,7 @@ class MiniProgramService
{
return self::qrcodeService()->appCodeUnlimit($scene, $page, $width, $autoColor, $lineColor, "develop");
}
/**
@ -305,7 +306,7 @@ class MiniProgramService
*/
public static function paymentPrepare($openid, $out_trade_no, $total_fee, $attach, $body, $detail = '', $trade_type = 'JSAPI', $options = [])
{
$order = self::paymentOrder($openid, $out_trade_no, $total_fee, $attach, $body, $detail, $trade_type, $options);
$result = self::paymentService()->prepare($order);
if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') {
@ -324,8 +325,8 @@ class MiniProgramService
exception('没有获取微信支付的预支付ID,请重新发起支付!');
}
exit;
}
}
}
@ -391,7 +392,7 @@ class MiniProgramService
* @return bool
*/
public static function payOrderRefund($orderNo, array $opt)
{
{
if (!isset($opt['pay_price'])) throw new AdminException('缺少pay_price');
if (SystemConfigService::get('pay_weixin_client_key') == '' || SystemConfigService::get('pay_weixin_client_cert') == '') throw new AdminException('请配置支付证书');
$totalFee = floatval(bcmul($opt['pay_price'], 100, 0));

@ -50,6 +50,7 @@ class Sns extends AbstractMiniProgram
'js_code' => $jsCode,
'grant_type' => 'authorization_code',
];
return $this->parseJSON('GET', [self::JSCODE_TO_SESSION, $params]);
}
}

Loading…
Cancel
Save