添加分享背景管理以及相应接口
parent
27576b78a1
commit
ce04904b10
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Repositories\ShareBg;
|
||||
use Carbon\Carbon;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Grid\Column;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use Dcat\Admin\Show;
|
||||
|
||||
class ShareBgController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new ShareBg(), function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('image')->image(100, 100);
|
||||
$grid->column('x');
|
||||
$grid->column('y');
|
||||
$grid->column('size');
|
||||
$grid->column('is_use')
|
||||
->if(function () {
|
||||
return Admin::user()->can('dcat.admin.share_bgs.edit');
|
||||
})
|
||||
->then(function (Column $column) {
|
||||
$column->switch();
|
||||
})
|
||||
->else(function (Column $column) {
|
||||
$column->bool();
|
||||
});
|
||||
$grid->column('sort');
|
||||
$grid->column('remark');
|
||||
$grid->column('created_at')->sortable();
|
||||
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
|
||||
/** 操作 **/
|
||||
//新增
|
||||
if (Admin::user()->can('dcat.admin.share_bgs.create')) {
|
||||
$grid->disableCreateButton(false);
|
||||
$grid->enableDialogCreate();
|
||||
}
|
||||
//修改
|
||||
$grid->showQuickEditButton(Admin::user()->can('dcat.admin.share_bgs.edit'));
|
||||
//删除以及自定义操作
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableDelete(Admin::user()->cannot('dcat.admin.share_bgs.destroy'));
|
||||
});
|
||||
|
||||
// /** 查询 **/
|
||||
// $grid->filter(function (Grid\Filter $filter) {
|
||||
// $filter->panel();
|
||||
// $filter->equal('address_id')->select(AdAddress::all()->pluck('name', 'id'))->width(3);
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new ShareBg(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('image');
|
||||
$show->field('x');
|
||||
$show->field('y');
|
||||
$show->field('size');
|
||||
$show->field('is_use');
|
||||
$show->field('sort');
|
||||
$show->field('remark');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new ShareBg(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->image('image')
|
||||
->move('share-bgs/'.Carbon::now()->toDateString())
|
||||
->saveFullUrl()
|
||||
->removable(false)
|
||||
->autoUpload()->required();
|
||||
$form->number('x')->min(0)->default(0)->required();
|
||||
$form->number('y')->min(0)->default(0)->required();
|
||||
$form->number('size')->min(0)->default(0)->required();
|
||||
$form->switch('is_use')->default(0)->required();
|
||||
$form->number('sort')->min(0)->default(0);
|
||||
$form->text('remark');
|
||||
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\ShareBg as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class ShareBg extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
|
|
@ -103,10 +103,14 @@ Route::group([
|
|||
'index', 'create', 'store', 'edit', 'update', 'destroy',
|
||||
])->names('order_reduce_ranges');
|
||||
|
||||
$router->resource('app_versions', 'AppVersionController')->only([
|
||||
$router->resource('app-versions', 'AppVersionController')->only([
|
||||
'index', 'create', 'store', 'edit', 'update', 'destroy',
|
||||
])->names('app_versions');
|
||||
|
||||
$router->resource('share-bgs', 'ShareBgController')->only([
|
||||
'index', 'create', 'store', 'edit', 'update', 'destroy',
|
||||
])->names('share_bgs');
|
||||
|
||||
/** api接口 **/
|
||||
$router->get('api/product-categories', 'ProductCategoryController@categories')->name('api.product_categories');
|
||||
$router->get('api/product-group-details', 'ProductGroupController@details')->name('api.product_group_details');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Endpoint\Api\Http\Controllers;
|
||||
|
||||
use App\Endpoint\Api\Http\Resources\ShareBgResource;
|
||||
use App\Models\ShareBg;
|
||||
use Illuminate\Http\Request;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
class ShareBgController extends Controller
|
||||
{
|
||||
/**
|
||||
* 分享背景图
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
return ShareBgResource::collection(ShareBg::where('is_use', true)->orderBy('sort', 'desc')->get());
|
||||
}
|
||||
|
||||
public function userQrCode(Request $request)
|
||||
{
|
||||
$inviteUri = config('settings.invite_uri').'/register?code=';
|
||||
return response()->json([
|
||||
'qr_code' => base64_encode(QrCode::format('png')->size(100)->margin(0)->generate($inviteUri.$request->user()->userInfo?->code)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Endpoint\Api\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ShareBgResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'image' => $this->image,
|
||||
'x' =>$this->x,
|
||||
'y' =>$this->y,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ use App\Endpoint\Api\Http\Controllers\Product\ProductFavoriteController;
|
|||
use App\Endpoint\Api\Http\Controllers\Product\ProductSkuController;
|
||||
use App\Endpoint\Api\Http\Controllers\Product\ProductViewLogController;
|
||||
use App\Endpoint\Api\Http\Controllers\PushController;
|
||||
use App\Endpoint\Api\Http\Controllers\ShareBgController;
|
||||
use App\Endpoint\Api\Http\Controllers\ShippingAddressController;
|
||||
use App\Endpoint\Api\Http\Controllers\ShoppingCartItemController;
|
||||
use App\Endpoint\Api\Http\Controllers\SmsCodeController;
|
||||
|
|
@ -121,6 +122,10 @@ Route::group([
|
|||
Route::get('click', [ClickController::class, 'index']);
|
||||
Route::post('click', [ClickController::class, 'click']);
|
||||
|
||||
//分享
|
||||
Route::get('share-bgs', [ShareBgController::class, 'index']);
|
||||
Route::post('user-qr-code', [ShareBgController::class, 'userQrCode']);
|
||||
|
||||
// 订单
|
||||
Route::get('order/statistics', StatisticsController::class);
|
||||
Route::post('order/verify-order', OrderVerifyController::class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ShareBg extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasDateTimeFormatter;
|
||||
|
||||
protected $casts = [
|
||||
'is_use'=>'bool',
|
||||
];
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Services\Push;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
|
@ -91,7 +92,7 @@ class UniPushService
|
|||
if ($response->successful()) {
|
||||
$data = $response->json();
|
||||
$token = $data['data']['token'];
|
||||
Cache::put($this->cacheKey, $data['data']['token'], $data['data']['expire_time']);
|
||||
Cache::put($this->cacheKey, $data['data']['token'], Carbon::createFromTimestampMs($data['data']['expire_time']));
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
|
|
@ -104,7 +105,7 @@ class UniPushService
|
|||
protected function post($uri, $params)
|
||||
{
|
||||
$token = $this->getToken();
|
||||
// dd($this->getUri($uri), $params);
|
||||
// dump($token, $this->getUri($uri), $params);
|
||||
$response = Http::withHeaders([
|
||||
'Accept' => 'application/json',
|
||||
'token' => $token,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
"laravel/sanctum": "^2.12",
|
||||
"laravel/tinker": "^2.5",
|
||||
"overtrue/easy-sms": "^2.0",
|
||||
"simplesoftwareio/simple-qrcode": "^4.2",
|
||||
"tucker-eric/eloquentfilter": "^3.0",
|
||||
"w7corp/easywechat": "^5.10"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "69a508e447b275532786ffcc0beff3aa",
|
||||
"content-hash": "8cdaea8176b066b5f779a5fe80f806af",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm89/stack-cors",
|
||||
|
|
@ -68,6 +68,65 @@
|
|||
},
|
||||
"time": "2021-03-11T06:42:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bacon/bacon-qr-code",
|
||||
"version": "2.0.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Bacon/BaconQrCode.git",
|
||||
"reference": "f73543ac4e1def05f1a70bcd1525c8a157a1ad09"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/f73543ac4e1def05f1a70bcd1525c8a157a1ad09",
|
||||
"reference": "f73543ac4e1def05f1a70bcd1525c8a157a1ad09",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"dasprid/enum": "^1.0.3",
|
||||
"ext-iconv": "*",
|
||||
"php": "^7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phly/keep-a-changelog": "^1.4",
|
||||
"phpunit/phpunit": "^7 | ^8 | ^9",
|
||||
"squizlabs/php_codesniffer": "^3.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-imagick": "to generate QR code images"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"BaconQrCode\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-2-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ben Scholzen 'DASPRiD'",
|
||||
"email": "mail@dasprids.de",
|
||||
"homepage": "https://dasprids.de/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "BaconQrCode is a QR code generator for PHP.",
|
||||
"homepage": "https://github.com/Bacon/BaconQrCode",
|
||||
"support": {
|
||||
"issues": "https://github.com/Bacon/BaconQrCode/issues",
|
||||
"source": "https://github.com/Bacon/BaconQrCode/tree/2.0.4"
|
||||
},
|
||||
"time": "2021-06-18T13:26:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "brick/math",
|
||||
"version": "0.9.3",
|
||||
|
|
@ -213,6 +272,59 @@
|
|||
],
|
||||
"time": "2021-09-13T08:41:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dasprid/enum",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DASPRiD/Enum.git",
|
||||
"reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/DASPRiD/Enum/zipball/5abf82f213618696dda8e3bf6f64dd042d8542b2",
|
||||
"reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7 | ^8 | ^9",
|
||||
"squizlabs/php_codesniffer": "^3.4"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DASPRiD\\Enum\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-2-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ben Scholzen 'DASPRiD'",
|
||||
"email": "mail@dasprids.de",
|
||||
"homepage": "https://dasprids.de/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "PHP 7.1 enum implementation",
|
||||
"keywords": [
|
||||
"enum",
|
||||
"map"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/DASPRiD/Enum/issues",
|
||||
"source": "https://github.com/DASPRiD/Enum/tree/1.0.3"
|
||||
},
|
||||
"time": "2020-10-02T16:03:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dcat/laravel-admin",
|
||||
"version": "2.1.5-beta",
|
||||
|
|
@ -4046,6 +4158,80 @@
|
|||
],
|
||||
"time": "2021-09-25T23:10:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "simplesoftwareio/simple-qrcode",
|
||||
"version": "4.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/SimpleSoftwareIO/simple-qrcode.git",
|
||||
"reference": "916db7948ca6772d54bb617259c768c9cdc8d537"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/SimpleSoftwareIO/simple-qrcode/zipball/916db7948ca6772d54bb617259c768c9cdc8d537",
|
||||
"reference": "916db7948ca6772d54bb617259c768c9cdc8d537",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"bacon/bacon-qr-code": "^2.0",
|
||||
"ext-gd": "*",
|
||||
"php": ">=7.2|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~1",
|
||||
"phpunit/phpunit": "~9"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-imagick": "Allows the generation of PNG QrCodes.",
|
||||
"illuminate/support": "Allows for use within Laravel."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"QrCode": "SimpleSoftwareIO\\QrCode\\Facades\\QrCode"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SimpleSoftwareIO\\QrCode\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Simple Software LLC",
|
||||
"email": "support@simplesoftware.io"
|
||||
}
|
||||
],
|
||||
"description": "Simple QrCode is a QR code generator made for Laravel.",
|
||||
"homepage": "https://www.simplesoftware.io/#/docs/simple-qrcode",
|
||||
"keywords": [
|
||||
"Simple",
|
||||
"generator",
|
||||
"laravel",
|
||||
"qrcode",
|
||||
"wrapper"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/SimpleSoftwareIO/simple-qrcode/issues",
|
||||
"source": "https://github.com/SimpleSoftwareIO/simple-qrcode/tree/4.2.0"
|
||||
},
|
||||
"time": "2021-02-08T20:43:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/eloquent-sortable",
|
||||
"version": "4.0.0",
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ return [
|
|||
'merchant_push_app_secret'=>'',
|
||||
'merchant_push_master_secret'=>'',
|
||||
|
||||
//邀请路径
|
||||
'invite_uri'=>'',
|
||||
|
||||
//app配置
|
||||
'user_center_is_open'=>true,
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateShareBgsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('share_bgs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('image')->comment('背景图');
|
||||
$table->unsignedInteger('x')->comment('起始点:x');
|
||||
$table->unsignedInteger('y')->comment('起始点:y');
|
||||
$table->unsignedInteger('size')->comment('二维码大小');
|
||||
$table->unsignedTinyInteger('is_use')->default(0)->comment('是否启用');
|
||||
$table->unsignedInteger('sort')->default(0)->comment('排序');
|
||||
$table->string('remark')->nullable()->comment('备注');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('share_bgs');
|
||||
}
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ class AdminMenuSeeder extends Seeder
|
|||
[
|
||||
'title' => 'App版本管理',
|
||||
'icon' => '',
|
||||
'uri' => 'app_versions',
|
||||
'uri' => 'app-versions',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
@ -122,6 +122,11 @@ class AdminMenuSeeder extends Seeder
|
|||
'icon' => '',
|
||||
'uri' => 'product-buynotes',
|
||||
],
|
||||
[
|
||||
'title' => '分享管理',
|
||||
'icon' => '',
|
||||
'uri' => 'share-bgs',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -214,6 +214,10 @@ class AdminPermissionSeeder extends Seeder
|
|||
'name' =>'App版本管理',
|
||||
'curd' => ['index', 'create', 'store', 'edit', 'update', 'destroy'],
|
||||
],
|
||||
'share_bgs'=>[
|
||||
'name'=>'分享背景',
|
||||
'curd' => ['index', 'create', 'store', 'edit', 'update', 'destroy'],
|
||||
],
|
||||
];
|
||||
try {
|
||||
DB::begintransaction();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'labels' => [
|
||||
'ShareBg' => '分享背景',
|
||||
'share-bg' => '分享背景',
|
||||
],
|
||||
'fields' => [
|
||||
'image' => '背景图',
|
||||
'x' => '起始点:x',
|
||||
'y' => '起始点:y',
|
||||
'size' => '二维码大小',
|
||||
'is_use' => '是否启用',
|
||||
'sort' => '排序',
|
||||
'remark' => '备注',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
];
|
||||
Loading…
Reference in New Issue