Initial commit: queue workspace

Made-with: Cursor
This commit is contained in:
apple
2026-03-21 02:55:24 +08:00
commit 78de918c37
12388 changed files with 1840126 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\services\product\label;
use app\dao\product\label\StoreProductLabelAuxiliaryDao;
use app\services\BaseServices;
use think\annotation\Inject;
/**
* 标签辅助表
* Class StoreProductLabelAuxiliaryServices
* @package app\services\product\label
* @mixin StoreProductLabelAuxiliaryDao
*/
class StoreProductLabelAuxiliaryServices extends BaseServices
{
/**
* @var StoreProductLabelAuxiliaryDao
*/
#[Inject]
protected StoreProductLabelAuxiliaryDao $dao;
/**
* 关联标签
* @param int $productId
* @param array $labelIds
* @return bool
*/
public function saveLabelRelation(int $productId, array $labelIds)
{
$data = [];
foreach ($labelIds as $labelId) {
$data[] = [
'product_id' => $productId,
'label_id' => $labelId
];
}
$this->dao->delete(['product_id' => $productId]);
if ($labelIds) {
$this->dao->saveAll($data);
}
return true;
}
}

View File

@@ -0,0 +1,110 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\services\product\label;
use app\dao\other\CategoryDao;
use app\services\BaseServices;
use crmeb\services\FormBuilder as Form;
use think\annotation\Inject;
use think\facade\Route as Url;
/**
* 商品标签分类
* Class StoreProductLabelCateServices
* @package app\services\product\brand
* @mixin CategoryDao
*/
class StoreProductLabelCateServices extends BaseServices
{
/**
* 在分类库中2
*/
const GROUP = 2;
/**
* @var CategoryDao
*/
#[Inject]
protected CategoryDao $dao;
/**
* 获取标签组列表(带标签)
* @param array $where
* @return array
*/
public function getProductLabelCateList(array $where)
{
[$page, $limit] = $this->getPageValue();
$count = $this->dao->count($where);
$list = $this->dao->getCateList($where, $page, $limit, ['*'], ['productLabel']);
if ($list) {
foreach ($list as &$item) {
$item['add_time'] = $item['add_time'] ? date('Y-m-d H:i:s', $item['add_time']) : '';
}
}
return compact('list', 'count');
}
/**
* 获取所有的商品标签分类
* @param int $type
* @param int $relation_id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAllProductLabelCate(int $type = 0, int $relation_id = 0)
{
$where = [
'type' => $type,
'relation_id' => $relation_id,
'group' => self::GROUP
];
return $this->dao->getAll($where);
}
/**
* 创建新增表单
* @return array
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function createForm()
{
return create_form('添加标签组', $this->form(), Url::buildUrl('/product/label_cate'), 'POST');
}
/**
* 创建编辑表单
* @param $id
* @return array
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function editForm(int $id)
{
$info = $this->dao->get($id);
return create_form('编辑标签组', $this->form($info), $this->url('/product/label_cate/' . $id), 'PUT');
}
/**
* 生成表单参数
* @param array $info
* @return array
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function form($info = [])
{
$f[] = Form::input('name', '标签组名称:', $info['name'] ?? '')->maxlength(30)->required();
$f[] = Form::number('sort', '排序:', (int)($info['sort'] ?? 0))->min(0)->min(0);
return $f;
}
}

View File

@@ -0,0 +1,172 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\services\product\label;
use app\dao\product\label\StoreProductLabelDao;
use app\services\BaseServices;
use crmeb\services\FormBuilder;
use think\annotation\Inject;
use think\facade\Route as Url;
/**
* 商品标签
* Class StoreProductLabelServices
* @package app\services\product\label
* @mixin StoreProductLabelDao
*/
class StoreProductLabelServices extends BaseServices
{
/**
* @var StoreProductLabelDao
*/
#[Inject]
protected StoreProductLabelDao $dao;
/**
* 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where)
{
[$page, $limit] = $this->getPageValue();
$list = $this->dao->getList($where, '*', $page, $limit);
$count = $this->dao->count($where);
return compact('list', 'count');
}
/**
* 获取所有商品标签
* @param int $type
* @param int $relation_id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAllLabel(int $type = 0, int $relation_id = 0)
{
$where['relation_id'] = $relation_id;
$where['type'] = $type;
return $this->dao->getList($where, 'id,label_name');
}
/**
* 获取商品标签 树形结构
* @param int $type
* @param int $relation_id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getProductLabelTreeList(int $type = 0, int $relation_id = 0)
{
/** @var StoreProductLabelCateServices $productLabelCateServices */
$productLabelCateServices = app()->make(StoreProductLabelCateServices::class);
$cate = $productLabelCateServices->getAllProductLabelCate($type, $relation_id);
$data = [];
$label = [];
$where = [];
if ($cate) {
foreach ($cate as $value) {
$data[] = [
'id' => $value['id'] ?? 0,
'value' => $value['id'] ?? 0,
'label_cate' => 0,
'label_name' => $value['name'] ?? '',
'label' => $value['name'] ?? '',
'relation_id' => $value['relation_id'] ?? 0,
'type' => $value['type'] ?? 0,
];
}
$label = $this->dao->getList($where);
if ($label) {
foreach ($label as &$item) {
$item['label'] = $item['label_name'];
$item['value'] = $item['id'];
}
}
}
return $this->get_tree_children($data, $label);
}
/**
* @param array $ids
* @return array|mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 等风来
* @email 136327134@qq.com
* @date 2022/11/1
*/
public function getLabelCache(array $ids, array $field = null, bool $isShow = true)
{
if (app()->config->get('cache.is_data')) {
$list = $this->dao->cacheInfoByIds($ids);
} else {
$list = null;
}
if (!$list) {
$list = $this->dao->getList(['ids' => $ids, 'status' => 1]);
foreach ($list as $item) {
$this->dao->cacheUpdate($item);
}
}
if ($field && $list) {
$newList = [];
array_multisort(array_column($list, 'sort'), SORT_DESC, array_column($list, 'id'), SORT_ASC, $list);
foreach ($list as $item) {
$data = [];
//标签不在移动端展示
if ($isShow && isset($item['is_show']) && !$item['is_show']) {
continue;
}
foreach ($field as $k) {
$data[$k] = $item[$k] ?? null;
}
$newList[] = $data;
}
$list = $newList;
}
return $list;
}
/**
* 获取商品标签表单
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getLabelForm()
{
/** @var StoreProductLabelCateServices $service */
$service = app()->make(StoreProductLabelCateServices::class);
$options = $service->getAllProductLabelCate();
$data = [];
foreach ($options as $option) {
$data[] = ['label' => $option['name'], 'value' => $option['id']];
}
$rule = [
FormBuilder::select('label_cate', '标签分组')->options($data),
FormBuilder::input('label_name', '标签名称')->maxlength(20),
];
return create_form('添加商品标签', $rule, Url::buildUrl('/product/label/0'), 'POST');
}
}