修改:典藏室 - 添加唯一编号管理
This commit is contained in:
parent
bb0eeb10ba
commit
5d58fb24e9
|
|
@ -4,6 +4,8 @@ namespace Yunshop\CollectionRoom;
|
|||
|
||||
|
||||
|
||||
use Yunshop\CollectionRoom\models\CollectionRoomIdentifierModel;
|
||||
|
||||
class PluginApplication extends \app\common\services\PluginApplication{
|
||||
|
||||
protected function setMenuConfig(){
|
||||
|
|
@ -54,6 +56,29 @@ class PluginApplication extends \app\common\services\PluginApplication{
|
|||
],
|
||||
]
|
||||
],
|
||||
'plugin_collection_room_identifier' => [
|
||||
'name' => '编号管理',
|
||||
'permit' => 1,
|
||||
'menu' => 1,
|
||||
'icon' => '',
|
||||
'url' => 'plugin.collection-room.admin.identifier.index',
|
||||
'url_params' => '',
|
||||
'item' => 'plugin_collection_room_identifier',
|
||||
'parents' => ['collection-room'],
|
||||
'child' => [
|
||||
// 权限补充
|
||||
'plugin_collection_room_identifier_index' => [
|
||||
'name' => '编号管理',
|
||||
'url' => 'plugin.collection-room.admin.index.index',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'plugin_collection_room_identifier_index',
|
||||
'parents' => ['collection-room','plugin_collection_room_identifier']
|
||||
]
|
||||
]
|
||||
],
|
||||
'plugin_collection_room_set' => [
|
||||
'name' => '基本设置',
|
||||
'permit' => 1,
|
||||
|
|
@ -80,6 +105,11 @@ class PluginApplication extends \app\common\services\PluginApplication{
|
|||
]);
|
||||
}
|
||||
|
||||
public function register(){
|
||||
CollectionRoomIdentifierModel::createDefaultData();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function boot(){
|
||||
$events = app('events');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
namespace Yunshop\CollectionRoom\admin;
|
||||
|
||||
|
||||
use app\common\components\BaseController;
|
||||
use app\common\helpers\PaginationHelper;
|
||||
use Yunshop\CollectionRoom\models\CollectionRoomIdentifierModel;
|
||||
|
||||
class IdentifierController extends BaseController{
|
||||
/**
|
||||
* Common: 进入列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/27 10:21
|
||||
* @return array|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function index(){
|
||||
//参数获取
|
||||
$search = request()->input('search');
|
||||
// 获取列表信息
|
||||
$result = CollectionRoomIdentifierModel::getList($search);
|
||||
$data = [
|
||||
'list' => $result['data'],
|
||||
'pager' => PaginationHelper::show($result['total'],$result['current_page'],$result['per_page']),
|
||||
'search' => $search
|
||||
];
|
||||
|
||||
return view('Yunshop\CollectionRoom::identifier.index',$data)->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ class IndexController extends BaseController{
|
|||
$isSubmit = (int)request()->input('is_submit');
|
||||
// 判断:是否为提交信息
|
||||
if($isSubmit == 1){
|
||||
if($uniqueNumber <= 0 || $uniqueNumber > 5000) return $this->errorJson('编号必须大于0且小于5000!');
|
||||
if($uniqueNumber <= 0 || $uniqueNumber >= 5000) return $this->errorJson('编号必须大于0且小于等于5000!');
|
||||
try{
|
||||
// 判断:当前编号是否已经存在
|
||||
$isHas = (int)CollectionRoomModel::uniacid()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/3/18
|
||||
* Time: 14:27
|
||||
*/
|
||||
|
||||
namespace Yunshop\CollectionRoom\models;
|
||||
|
||||
use app\common\models\BaseModel;
|
||||
use app\common\models\Member;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
|
||||
|
||||
class CollectionRoomIdentifierModel extends BaseModel{
|
||||
|
||||
public $table = 'yz_collection_room_identifier';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'uniacid',
|
||||
'unique_number',
|
||||
'encryption',
|
||||
'encryption_type',
|
||||
];
|
||||
// 生成默认编号参数信息
|
||||
private static $num = 5000;// 生成数量
|
||||
private static $encryptionType = 'md5';// 默认加密方式 支持hash_algos中的加密方式
|
||||
|
||||
|
||||
/**
|
||||
* Common: 列表信息获取
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/27 9:44
|
||||
* @param $search
|
||||
* @return array
|
||||
*/
|
||||
public function getList($search){
|
||||
// 条件生成
|
||||
$where = [];
|
||||
if($search['unique_number'] > 0) $where[] = ['yz_collection_room_identifier.unique_number','=',$search['unique_number']];
|
||||
if(!empty($search['encryption'])) $where[] = ['yz_collection_room_identifier.encryption','=',strtolower($search['encryption'])];
|
||||
// 列表获取
|
||||
$field = [
|
||||
'yz_collection_room_identifier.id',
|
||||
'yz_collection_room_identifier.unique_number',
|
||||
'yz_collection_room_identifier.encryption',
|
||||
'yz_collection_room_identifier.encryption_type',
|
||||
'yz_collection_room.id as collection_room_id'
|
||||
];
|
||||
|
||||
$list = self::uniacid()
|
||||
->leftJoin('yz_collection_room','yz_collection_room.unique_number','yz_collection_room_identifier.unique_number')
|
||||
->select($field)
|
||||
->where($where)
|
||||
->orderBy('yz_collection_room_identifier.unique_number','ASC')
|
||||
->paginate(10);
|
||||
|
||||
return $list ? $list->toArray() : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Common: 生成默认数据
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/27 9:52
|
||||
*/
|
||||
public static function createDefaultData(){
|
||||
$count = (int)self::uniacid()->count();
|
||||
// 没有数据 生成默认数据
|
||||
if($count <= 0){
|
||||
$uniacid = \YunShop::app()->uniacid;
|
||||
$insertData = [];
|
||||
for($i = 1;$i <= self::$num;$i++){
|
||||
$insertData[] = [
|
||||
'uniacid' => $uniacid,
|
||||
'unique_number' => $i,
|
||||
'encryption' => hash(self::$encryptionType,$i),
|
||||
'encryption_type' => self::$encryptionType,
|
||||
];
|
||||
}
|
||||
|
||||
self::insert($insertData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<script src="{!!resource_absolute('static/js/xlsx.full.min.js')!!}"></script>
|
||||
@extends('layouts.base')
|
||||
<style>
|
||||
.panel-body .label{
|
||||
font-size: 14px!important;
|
||||
}
|
||||
</style>
|
||||
@section('content')
|
||||
<div class="w1200 m0a" id="storeManagerIndex">
|
||||
{{--顶部搜索--}}
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-body">
|
||||
<form action="" method="post" class="form-horizontal" role="form" id="form1">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-11 col-xs-12">
|
||||
<div class="row row-fix tpl-category-container" >
|
||||
<div class="col-xs-12 col-sm-8 col-lg-3">
|
||||
<input class="form-control" name="search[unique_number]" id="" type="text" value="{{ $search['unique_number'] }}" placeholder="唯一编号">
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-8 col-lg-3">
|
||||
<input class="form-control" name="search[encryption]" id="" type="text" value="{{ $search['encryption'] }}" placeholder="加密编号">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-xs-12 col-sm-6 col-lg-6">
|
||||
<input name="page" value="1" class="hide">
|
||||
<button class="btn btn-success" id="search"><i class="fa fa-search"></i> 搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{{--信息列表--}}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body" style="padding-top: 0;margin-bottom: 30px;overflow: auto;padding-right: 30px;">
|
||||
<table class="table" style="min-width:1500px;overflow: auto;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:center;">唯一编号</th>
|
||||
<th style="text-align:center;">是否分配</th>
|
||||
<th style="text-align:center;">加密编号(原始)</th>
|
||||
<th style="text-align:center;">加密编号(字母大写)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($list as $item)
|
||||
<tr style="height: 50px;">
|
||||
<td style="text-align:center;">{{ $item['unique_number'] }}</td>
|
||||
<td style="text-align:center;">
|
||||
@if((int)$item['collection_room_id'] > 0)
|
||||
<span class="label label-success">已分配(画ID:{{(int)$item['collection_room_id']}})</span>
|
||||
@else
|
||||
<span class="label label-danger">未分配</span>
|
||||
@endif
|
||||
</td>
|
||||
<td style="text-align:center;">{{ $item['encryption'] }}</td>
|
||||
<td style="text-align:center;">{{ strtoupper($item['encryption']) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
{!! $pager !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Loading…
Reference in New Issue