feat:DLC 功能
parent
112f25f319
commit
ab52efd1d6
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\WeChat;
|
||||
use Illuminate\Http\Request;
|
||||
use Yo;
|
||||
|
||||
class WeChatController extends Controller
|
||||
{
|
||||
public function mp_login($we_chat, $code)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid='
|
||||
. $we_chat->app_id
|
||||
. '&secret=' . $we_chat->app_secret
|
||||
. '&js_code=' . $code . '&grant_type=authorization_code';
|
||||
$info = file_get_contents($url);
|
||||
$json = json_decode($info);
|
||||
return get_object_vars($json);
|
||||
}
|
||||
|
||||
public function login($code, $app_id)
|
||||
{
|
||||
$we_chat = WeChat::where('app_id', $app_id)->first();
|
||||
$login = false;
|
||||
if (!$we_chat) return $login;
|
||||
switch ($we_chat->type) {
|
||||
case 1:
|
||||
|
||||
break;
|
||||
case 2:
|
||||
$login = $this->mp_login($we_chat, $code);
|
||||
break;
|
||||
}
|
||||
return $login;
|
||||
}
|
||||
|
||||
public function login_test(Request $request)
|
||||
{
|
||||
$code = $request->post('code');
|
||||
$app_id = $request->post('app_id');
|
||||
return Yo::echo([
|
||||
'info' => $this->login($code, $app_id)
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WeChatPayController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WeChat extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WeChatPay extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('we_chats', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 50)->comment('名称');
|
||||
$table->tinyInteger('type')->comment('1-公众号 2-小程序');
|
||||
$table->string('app_id', 80)->comment('小程序ID')->index();
|
||||
$table->string('app_secret', 100)->comment('小程序密钥')->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('we_chats');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('we_chat_pays', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('app_id', 80)->comment('APPID')->index();
|
||||
$table->string('pay_id', 20)->comment('商户号');
|
||||
$table->string('number', 100)->comment('证书编号');
|
||||
$table->string('v3', 100)->comment('API KEY V3');
|
||||
$table->string('key', 200)->comment('证书 Key');
|
||||
$table->string('crt', 200)->comment('证书 Crt');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('we_chat_pays');
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue