修复:供应商管理后台 - 商品相关接口报错处理,可以显示部分数据

修改:供应商管理后台 - 接口成功和错误抛出方法使用错误,导致大部分接口报错,没有正常返回数据
This commit is contained in:
wuhui_zzw 2024-01-09 15:49:49 +08:00
parent fbb76380c0
commit b0e611a712
29 changed files with 279 additions and 243 deletions

View File

@ -9,6 +9,8 @@ use crmeb\services\UploadService;
use Swoole\Lock;
use think\db\BaseQuery;
use think\facade\Log;
use crmeb\services\FormBuilder as Form;
use think\exception\ValidateException;
if (!function_exists('go')) {
function go(): bool
@ -1242,4 +1244,32 @@ if (!function_exists('get_file_link')) {
}
}
}
if (!function_exists('create_form')) {
/**
* 表单生成方法
* @param string $title
* @param array $field
* @param $url
* @param string $method
* @return array
* @throws \FormBuilder\Exception\FormBuilderException
*/
function create_form(string $title, array $field, $url, string $method = 'POST')
{
$form = Form::createForm((string)$url);//提交地址
$form->setMethod($method);//提交方式
$form->setRule($field);//表单字段
$form->setTitle($title);//表单标题
$rules = $form->formRule();
$title = $form->getTitle();
$action = $form->getAction();
$method = $form->getMethod();
$info = '';
$status = true;
$methodData = ['POST', 'PUT', 'GET', 'DELETE'];
if (!in_array(strtoupper($method), $methodData)) {
throw new ValidateException('请求方式有误');
}
return compact('rules', 'title', 'action', 'method', 'info', 'status');
}
}

View File

@ -61,4 +61,28 @@ class StoreBrandDao extends BaseDao
}
/**
* 获取品牌列表
* @param array $where
* @param array $with
* @param array $field
* @param int $page
* @param int $limit
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where, array $with = [], array $field = ['*'], int $page = 0, int $limit = 0)
{
return $this->search($where)->field($field)
->when(in_array('product', $with), function ($query) use ($with) {
$with = array_merge(array_diff($with, ['product']), ['product' => function ($que) {
$que->field(['brand_id', "count(`brand_id`) as brand_num"])->where('is_del', 0)->group('brand_id');
}]);
$query->with($with);
})->when($page && $limit, function ($query) use($page, $limit) {
$query->page($page, $limit);
})->order('sort desc,brand_id desc')->select()->toArray();
}
}

View File

@ -58,7 +58,7 @@ class Login
$key = 'supplier_login_captcha_' . $account;
return app('json')->success(['is_captcha' => Cache::get($key) > 2]);
return app('json')->success('',['is_captcha' => Cache::get($key) > 2]);
}
/**
@ -67,7 +67,7 @@ class Login
public function ajcaptcha(Request $request)
{
$captchaType = $request->get('captchaType');
return app('json')->success(aj_captcha_create($captchaType));
return app('json')->success('',aj_captcha_create($captchaType));
}
/**
@ -96,7 +96,7 @@ class Login
*/
public function info()
{
return app('json')->success($this->services->getLoginInfo());
return app('json')->success('',$this->services->getLoginInfo());
}
/**
@ -145,7 +145,7 @@ class Login
$res = $this->services->login($account, $password, 'supplier');
if ($res) Cache::delete($key);
return app('json')->success($res);
return app('json')->success('',$res);
}
/**

View File

@ -81,7 +81,7 @@ class Order extends AuthController
/** @var DeliveryServiceServices $deliverServices */
$deliverServices = app()->make(DeliveryServiceServices::class);
$data = $deliverServices->getDeliveryList(2, (int)$this->supplierId);
return $this->success($data);
return app('json')->success('',$data);
}
/**

View File

@ -84,7 +84,7 @@ class ExportExcel extends AuthController
$where['is_system_del'] = 0;
$where['supplier_id'] = $this->supplierId;
$data = $services->getExportList($where, $with, $this->service->limit);
return $this->success($this->service->storeOrder($data, $type));
return app('json')->success($this->service->storeOrder($data, $type));
}
/**
@ -102,11 +102,11 @@ class ExportExcel extends AuthController
/** @var QueueServices $queueService */
$queueService = app()->make(QueueServices::class);
$queueInfo = $queueService->getQueueOne(['id' => $id]);
if (!$queueInfo) return $this->fail("数据不存在");
if (!$queueInfo) return app('json')->fail("数据不存在");
$queueValue = json_decode($queueInfo['queue_in_value'], true);
if (!$queueValue || !isset($queueValue['cacheType'])) return $this->fail("数据参数缺失");
if (!$queueValue || !isset($queueValue['cacheType'])) return app('json')->fail("数据参数缺失");
$data = $auxiliaryService->getExportData(['binding_id' => $id, 'type' => $cacheType], $this->service->limit);
return $this->success($this->service->batchOrderDelivery($data, $queueType));
return app('json')->success($this->service->batchOrderDelivery($data, $queueType));
}
/**
@ -118,7 +118,7 @@ class ExportExcel extends AuthController
/** @var ExpressServices $expressService */
$expressService = app()->make(ExpressServices::class);
$data = $expressService->apiExpressList();
return $this->success($this->service->expressList($data));
return app('json')->success($this->service->expressList($data));
}
/**
@ -135,6 +135,6 @@ class ExportExcel extends AuthController
$where['is_del'] = 0;
$where['supplier_id'] = $this->supplierId;
$data = $services->getList($where);
return $this->success($this->service->SupplierFinanceRecord($data['list'] ?? []));
return app('json')->success($this->service->SupplierFinanceRecord($data['list'] ?? []));
}
}

View File

@ -133,7 +133,7 @@ class SystemAttachment extends AuthController
['pid', 0],//分类ID
]);
$fileHandle = $this->request->file($data['file']);
if (!$fileHandle) return $this->fail('上传信息为空');
if (!$fileHandle) return app('json')->fail('上传信息为空');
$res = $this->service->videoUpload($data, $fileHandle, 4, (int)$this->supplierId);
return app('json')->success($res);
}

View File

@ -45,7 +45,7 @@ class SystemAttachmentCategory extends AuthController
$where['type'] = 4;
$where['relation_id'] = $this->supplierId;
if ($where['name'] != '') $where['pid'] = '';
return app('json')->success($this->service->getAll($where));
return app('json')->success('',$this->service->getAll($where));
}
/**
@ -58,7 +58,7 @@ class SystemAttachmentCategory extends AuthController
[$file_type] = $this->request->postMore([
['file_type', 1]
], true);
return app('json')->success($this->service->createForm($id, 4, $this->supplierId, (int)$file_type));
return app('json')->success('',$this->service->createForm($id, 4, $this->supplierId, (int)$file_type));
}
/**
@ -92,7 +92,7 @@ class SystemAttachmentCategory extends AuthController
[$file_type] = $this->request->postMore([
['file_type', 1]
], true);
return app('json')->success($this->service->editForm($id, 4, $this->supplierId, (int)$file_type));
return app('json')->success('',$this->service->editForm($id, 4, $this->supplierId, (int)$file_type));
}
/**

View File

@ -62,7 +62,7 @@ class SupplierExtract extends AuthController
'supplier_id' => $this->supplierId,
'is_del' => 0,
];
return app('json')->success($this->services->index($where,$whereData));
return app('json')->success('',$this->services->index($where,$whereData));
}
/**

View File

@ -51,7 +51,7 @@ class SupplierFlowingWater extends AuthController
$where['keyword'] = $this->request->param('keyword', '');
$where['supplier_id'] = $this->supplierId;
$where['is_del'] = 0;
return app('json')->success($this->services->getList($where));
return app('json')->success('',$this->services->getList($where));
}
/**
@ -82,7 +82,7 @@ class SupplierFlowingWater extends AuthController
*/
public function getType()
{
return app('json')->success($this->services->type);
return app('json')->success('',$this->services->type);
}
/**
@ -96,7 +96,7 @@ class SupplierFlowingWater extends AuthController
['data', '', '', 'time'],
]);
$where['supplier_id'] = $this->supplierId;
return app('json')->success($this->services->getFundRecord($where));
return app('json')->success('',$this->services->getFundRecord($where));
}
/**
@ -117,6 +117,6 @@ class SupplierFlowingWater extends AuthController
unset($where['ids']);
$where['is_del'] = 0;
$where['supplier_id'] = $this->supplierId;
return app('json')->success($this->services->getList($where));
return app('json')->success('',$this->services->getList($where));
}
}

View File

@ -1,13 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\supplier\product;
use app\controller\supplier\AuthController;
@ -52,7 +43,7 @@ class StoreBrand extends AuthController
]);
$where['is_del'] = 0;
$data = $this->service->getList($where);
return $this->success($data);
return app('json')->success('',$data);
}
/**
@ -63,9 +54,9 @@ class StoreBrand extends AuthController
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function cascader_list($type = 1)
{
return $this->success($this->service->cascaderList($type));
public function cascader_list($type = 1){
return app('json')->success('',$this->service->cascaderList($type));
}
/**
@ -75,9 +66,9 @@ class StoreBrand extends AuthController
*/
public function set_show($is_show = '', $id = '')
{
if ($is_show == '' || $id == '') return $this->fail('缺少参数');
if ($is_show == '' || $id == '') return app('json')->fail('缺少参数');
$this->service->setShow($id, $is_show);
return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
return app('json')->success($is_show == 1 ? '显示成功' : '隐藏成功');
}
/**
@ -93,13 +84,13 @@ class StoreBrand extends AuthController
['is_show', 0]
]);
if (!$data['brand_name']) {
return $this->fail('请输入品牌名称');
return app('json')->fail('请输入品牌名称');
}
if (iconv_strlen($data['brand_name'], 'UTF-8') > 10) {
return $this->fail('品牌名称过长');
return app('json')->fail('品牌名称过长');
}
$this->service->createData($data);
return $this->success('添加品牌成功!');
return app('json')->success('添加品牌成功!');
}
/**
@ -116,13 +107,13 @@ class StoreBrand extends AuthController
['is_show', 0]
]);
if (!$data['brand_name']) {
return $this->fail('请输入品牌名称');
return app('json')->fail('请输入品牌名称');
}
if (iconv_strlen($data['brand_name'], 'UTF-8') > 10) {
return $this->fail('品牌名称过长');
return app('json')->fail('品牌名称过长');
}
$this->service->editData($id, $data);
return $this->success('修改成功!');
return app('json')->success('修改成功!');
}
/**
@ -133,6 +124,6 @@ class StoreBrand extends AuthController
public function delete($id)
{
$this->service->del((int)$id);
return $this->success('删除成功!');
return app('json')->success('删除成功!');
}
}

View File

@ -73,7 +73,7 @@ class StoreProduct extends AuthController
$where['cate_id'] = $cateId;
$where['supplier_id'] = $this->supplierId;
$list = $this->services->getHeader(0, $where);
return app('json')->success(compact('list'));
return app('json')->success('',compact('list'));
}
/**
@ -103,7 +103,7 @@ class StoreProduct extends AuthController
$where['relation_id'] = $this->supplierId;
$where['type'] = 2;
$data = $this->services->getList($where);
return app('json')->success($data);
return app('json')->success('',$data);
}
/**
@ -139,7 +139,7 @@ class StoreProduct extends AuthController
}
unset($where['cate_id']);
$list = $this->services->searchList($where);
return $this->success($list);
return app('json')->success('',$list);
}
/**
@ -152,7 +152,7 @@ class StoreProduct extends AuthController
*/
public function cascader_list(StoreProductCategoryServices $services)
{
return app('json')->success($services->cascaderList(2, (int)$this->supplierId));
return app('json')->success('',$services->cascaderList(2, (int)$this->supplierId));
}
/**
@ -164,7 +164,7 @@ class StoreProduct extends AuthController
*/
public function read($id = 0)
{
return app('json')->success($this->services->getInfo((int)$id));
return app('json')->success('',$this->services->getInfo((int)$id));
}
/**
@ -247,7 +247,7 @@ class StoreProduct extends AuthController
$this->services->cacheTag()->clear();
$attrServices->cacheTag()->clear();
return $this->success($id ? '保存商品信息成功' : '添加商品成功!');
return app('json')->success($id ? '保存商品信息成功' : '添加商品成功!');
}
/**
@ -299,7 +299,7 @@ class StoreProduct extends AuthController
}
}
}
return app('json')->success($service->get_tree_children($data, $label));
return app('json')->success('',$service->get_tree_children($data, $label));
}
/**
@ -310,9 +310,9 @@ class StoreProduct extends AuthController
*/
public function set_show($is_show = '', $id = '', StoreBranchProductServices $services)
{
if (!$id) return $this->fail('缺少商品ID');
if (!$id) return app('json')->fail('缺少商品ID');
$services->setShow($this->supplierId, $id, $is_show);
return $this->success($is_show == 1 ? '上架成功' : '下架成功');
return app('json')->success($is_show == 1 ? '上架成功' : '下架成功');
}
/**
@ -322,9 +322,10 @@ class StoreProduct extends AuthController
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function get_rule()
{
return $this->success($this->services->getRule(2, (int)$this->supplierId));
public function get_rule(){
$data = $this->services->getRule(2, (int)$this->supplierId);
return app('json')->success('',$data);
}
/**
@ -336,7 +337,7 @@ class StoreProduct extends AuthController
*/
public function get_product_info($id = 0)
{
return $this->success($this->services->getInfo((int)$id));
return app('json')->success('',$this->services->getInfo((int)$id));
}
@ -344,9 +345,10 @@ class StoreProduct extends AuthController
* 获取运费模板列表
* @return mixed
*/
public function get_template()
{
return $this->success($this->services->getTemp(2, (int)$this->supplierId));
public function get_template(){
$data = $this->services->getTemp(2, (int)$this->supplierId);
return app('json')->success('',$data);
}
/**
@ -369,7 +371,7 @@ class StoreProduct extends AuthController
} else {
$re = $upload->getTempKeys();
}
return $re ? $this->success($re) : $this->fail($upload->getError());
return $re ? $this->success($re) : app('json')->fail($upload->getError());
}
/**
@ -381,9 +383,9 @@ class StoreProduct extends AuthController
public function getAttrs(StoreBranchProductAttrValueServices $services, $id)
{
if (!$id) {
return $this->fail('缺少商品ID');
return app('json')->fail('缺少商品ID');
}
return $this->success($services->getStoreProductAttr((int)$id));
return app('json')->success('',$services->getStoreProductAttr((int)$id));
}
/**
@ -398,7 +400,7 @@ class StoreProduct extends AuthController
$this->services->checkActivity($id);
$res = $this->services->del($id);
event('product.delete', [$id]);
return $this->success($res);
return app('json')->success('',$res);
}
/**
@ -416,7 +418,7 @@ class StoreProduct extends AuthController
]);
if ($id > 0 && $type == 1) $this->services->checkActivity($id);
$info = $this->services->getAttr($data, $id, $type, 2);
return $this->success(compact('info'));
return app('json')->success('',compact('info'));
}
/**
@ -428,20 +430,20 @@ class StoreProduct extends AuthController
public function saveProductAttrsStock(StoreProductAttrValueServices $services, $id)
{
if (!$id) {
return $this->fail('缺少商品ID');
return app('json')->fail('缺少商品ID');
}
[$attrs] = $this->request->getMore([
['attrs', []]
], true);
if (!$attrs) {
return $this->fail('请重新修改规格库存');
return app('json')->fail('请重新修改规格库存');
}
foreach ($attrs as $attr) {
if (!isset($attr['unique']) || !isset($attr['pm']) || !isset($attr['stock'])) {
return $this->fail('请重新修改规格库存');
return app('json')->fail('请重新修改规格库存');
}
}
return $this->success(['stock' => $services->saveProductAttrsStock((int)$id, $attrs)]);
return app('json')->success('',['stock' => $services->saveProductAttrsStock((int)$id, $attrs)]);
}
/**
@ -456,9 +458,9 @@ class StoreProduct extends AuthController
['where', []],
], true);
if ($all == 0) {//单页不走队列
if (empty($ids)) return $this->fail('请选择需要上架的商品');
if (empty($ids)) return app('json')->fail('请选择需要上架的商品');
$this->services->setShow($ids, 1);
return $this->success('上架成功');
return app('json')->success('上架成功');
}
if ($all == 1) {
$ids = [];
@ -475,7 +477,7 @@ class StoreProduct extends AuthController
$queueService->setQueueData($where, 'id', $ids, $type);
//加入队列
BatchHandleJob::dispatch(['up', $type]);
return $this->success('后台程序已执商品上架任务!');
return app('json')->success('后台程序已执商品上架任务!');
}
/**
@ -490,9 +492,9 @@ class StoreProduct extends AuthController
['where', []],
], true);
if ($all == 0) {//单页不走队列
if (empty($ids)) return $this->fail('请选择需要下架的商品');
if (empty($ids)) return app('json')->fail('请选择需要下架的商品');
$this->services->setShow($ids, 0);
return $this->success('下架成功');
return app('json')->success('下架成功');
}
if ($all == 1) {
$all_ids = $this->services->getColumn(['is_show' => 1, 'is_del' => 0, 'type' => 2, 'relation_id' => $this->supplierId], 'id');
@ -511,7 +513,7 @@ class StoreProduct extends AuthController
$queueService->setQueueData($where, 'id', $ids, $type);
//加入队列
BatchHandleJob::dispatch(['down', $type]);
return $this->success('后台程序已执商品下架任务!');
return app('json')->success('后台程序已执商品下架任务!');
}
/**
@ -528,9 +530,9 @@ class StoreProduct extends AuthController
['where', ""],
['data', []]
], true);
if (!$ids && $all == 0) return $this->fail('请选择批处理商品');
if (!$ids && $all == 0) return app('json')->fail('请选择批处理商品');
if (!$data) {
return $this->fail('请选择批处理数据');
return app('json')->fail('请选择批处理数据');
}
if (isset($where['type'])) {
$where['status'] = $where['type'];

View File

@ -54,7 +54,7 @@ class StoreProductCategory extends AuthController
// $where['relation_id'] = $this->supplierId;
$where['pid'] = (int)$where['pid'];
$data = $this->service->getList($where);
return $this->success($data);
return app('json')->success('',$data);
}
/**
@ -64,7 +64,7 @@ class StoreProductCategory extends AuthController
public function tree_list($type)
{
$list = $this->service->getTierList(1, $type);
return $this->success($list);
return app('json')->success('',$list);
}
/**
@ -77,7 +77,7 @@ class StoreProductCategory extends AuthController
*/
public function cascader_list($type = 1)
{
return $this->success($this->service->cascaderList(0, 0, !$type));
return app('json')->success('',$this->service->cascaderList(0, 0, !$type));
}
/**
@ -87,9 +87,9 @@ class StoreProductCategory extends AuthController
*/
public function set_show($is_show = '', $id = '')
{
if ($is_show == '' || $id == '') return $this->fail('缺少参数');
if ($is_show == '' || $id == '') return app('json')->fail('缺少参数');
$this->service->setShow($id, $is_show);
return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
return app('json')->success($is_show == 1 ? '显示成功' : '隐藏成功');
}
/**
@ -99,7 +99,7 @@ class StoreProductCategory extends AuthController
*/
public function create()
{
return $this->success($this->service->createForm(1));
return app('json')->success($this->service->createForm(1));
}
/**
@ -117,12 +117,12 @@ class StoreProductCategory extends AuthController
['is_show', 0]
]);
if (!$data['cate_name']) {
return $this->fail('请输入分类名称');
return app('json')->fail('请输入分类名称');
}
$data['type'] = 2;
$data['relation_id'] = $this->supplierId;
$this->service->createData($data);
return $this->success('添加分类成功!');
return app('json')->success('添加分类成功!');
}
/**
@ -133,7 +133,7 @@ class StoreProductCategory extends AuthController
*/
public function edit($id)
{
return $this->success($this->service->editForm((int)$id, 1));
return app('json')->success($this->service->editForm((int)$id, 1));
}
/**
@ -152,10 +152,10 @@ class StoreProductCategory extends AuthController
['is_show', 0]
]);
if (!$data['cate_name']) {
return $this->fail('请输入分类名称');
return app('json')->fail('请输入分类名称');
}
$this->service->editData($id, $data);
return $this->success('修改成功!');
return app('json')->success('修改成功!');
}
/**
@ -166,6 +166,6 @@ class StoreProductCategory extends AuthController
public function delete($id)
{
$this->service->del((int)$id);
return $this->success('删除成功!');
return app('json')->success('删除成功!');
}
}

View File

@ -44,7 +44,7 @@ class StoreProductReply extends AuthController
$where['type'] = 2;
$where['relation_id'] = $this->supplierId;
$list = $this->services->sysPage($where);
return $this->success($list);
return app('json')->success('',$list);
}
/**
@ -55,7 +55,7 @@ class StoreProductReply extends AuthController
public function delete($id)
{
$this->services->del($id);
return $this->success('删除成功!');
return app('json')->success('删除成功!');
}
/**
@ -69,7 +69,7 @@ class StoreProductReply extends AuthController
['content', '']
], true);
$this->services->setReply((int)$id, $content, 2, (int)$this->supplierId);
return $this->success('回复成功!');
return app('json')->success('回复成功!');
}
}

View File

@ -45,7 +45,7 @@ class StoreProductRule extends AuthController
$where['type'] = 2;
$where['relation_id'] = $this->supplierId;
$list = $this->services->getList($where);
return $this->success($list);
return app('json')->success('',$list);
}
/**
@ -60,12 +60,12 @@ class StoreProductRule extends AuthController
['spec', []]
]);
if (!$data['rule_name']) {
return $this->fail('请输入分类名称');
return app('json')->fail('请输入分类名称');
}
$data['type'] = 2;
$data['relation_id'] = $this->supplierId;
$this->services->save($id, $data, 2, (int)$this->supplierId);
return $this->success('保存成功!');
return app('json')->success('保存成功!');
}
/**
@ -76,7 +76,7 @@ class StoreProductRule extends AuthController
public function read($id)
{
$info = $this->services->getInfo($id);
return $this->success($info);
return app('json')->success('',$info);
}
/**
@ -87,13 +87,13 @@ class StoreProductRule extends AuthController
public function delete($id)
{
if (!$id) {
return $this->fail('缺少ID');
return app('json')->fail('缺少ID');
}
$info = $this->services->getInfo((int)$id);
if (!$info) {
return $this->fail('删除的数据不存在');
return app('json')->fail('删除的数据不存在');
}
$this->services->delete($id);
return $this->success('删除成功!');
return app('json')->success('删除成功!');
}
}

View File

@ -40,9 +40,10 @@ class StoreProductUnit extends AuthController
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAllUnit()
{
return $this->success($this->services->getAllUnitList(2, (int)$this->supplierId));
public function getAllUnit(){
$data = $this->services->getAllUnitList(2, (int)$this->supplierId);
return app('json')->success('',$data);
}
/**
@ -59,7 +60,7 @@ class StoreProductUnit extends AuthController
$where['relation_id'] = $this->supplierId;
$where['status'] = 1;
$where['is_del'] = 0;
return $this->success($this->services->getUnitList($where));
return app('json')->success('',$this->services->getUnitList($where));
}
/**
@ -69,7 +70,7 @@ class StoreProductUnit extends AuthController
*/
public function create()
{
return $this->success($this->services->createForm());
return app('json')->success('',$this->services->createForm());
}
/**
@ -88,13 +89,13 @@ class StoreProductUnit extends AuthController
validate(\app\validate\admin\product\StoreProductUnitValidate::class)->scene('get')->check(['name' => $data['name']]);
if ($this->services->getCount(['name' => $data['name'], 'is_del' => 0, 'type' => 2, 'relation_id' => $this->supplierId])) {
return $this->fail('单位已经存在,请勿重复添加');
return app('json')->fail('单位已经存在,请勿重复添加');
}
$data['add_time'] = time();
if ($this->services->save($data)) {
return $this->success('保存成功');
return app('json')->success('保存成功');
} else {
return $this->fail('保存失败');
return app('json')->fail('保存失败');
}
}
@ -107,13 +108,13 @@ class StoreProductUnit extends AuthController
public function read($id)
{
if (!$id) {
return $this->fail('缺少ID');
return app('json')->fail('缺少ID');
}
$info = $this->services->get($id);
if (!$info) {
return $this->fail('获取商品单位失败');
return app('json')->fail('获取商品单位失败');
}
return $this->success($info->toArray());
return app('json')->success('',$info->toArray());
}
/**
@ -124,7 +125,7 @@ class StoreProductUnit extends AuthController
*/
public function edit($id)
{
return $this->success($this->services->updateForm((int)$id));
return app('json')->success('',$this->services->updateForm((int)$id));
}
/**
@ -145,12 +146,12 @@ class StoreProductUnit extends AuthController
$unit = $this->services->getOne(['name' => $data['name'], 'is_del' => 0, 'type' => 2, 'relation_id' => $this->supplierId]);
if ($unit && $unit['id'] != $id) {
return $this->fail('单位名称已经存在');
return app('json')->fail('单位名称已经存在');
}
if ($this->services->update($id, $data)) {
return $this->success('修改成功');
return app('json')->success('修改成功');
} else {
return $this->fail('修改失败');
return app('json')->fail('修改失败');
}
}
@ -163,11 +164,11 @@ class StoreProductUnit extends AuthController
public function delete($id)
{
if (!$id || !($info = $this->services->get($id))) {
return $this->fail('删除的数据不存在');
return app('json')->fail('删除的数据不存在');
}
if ($info && $info['is_del'] == 0) {
$this->services->update($id, ['is_del' => 1]);
}
return $this->success('删除成功');
return app('json')->success('删除成功');
}
}

View File

@ -50,7 +50,7 @@ class StoreProductEnsure extends AuthController
]);
$where['relation_id'] = $this->supplierId;
$where['type'] = 2;
return $this->success($this->services->getEnsureList($where));
return app('json')->success($this->services->getEnsureList($where));
}
/**
@ -60,9 +60,10 @@ class StoreProductEnsure extends AuthController
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function allEnsure()
{
return $this->success($this->services->getAllEnsure(2, (int)$this->supplierId));
public function allEnsure(){
$data = $this->services->getAllEnsure(2, (int)$this->supplierId);
return app('json')->success('',$data);
}
@ -73,7 +74,7 @@ class StoreProductEnsure extends AuthController
*/
public function create()
{
return $this->success($this->services->createForm());
return app('json')->success($this->services->createForm());
}
/**
@ -89,17 +90,17 @@ class StoreProductEnsure extends AuthController
['sort', 0],
]);
if (!$data['name']) {
return $this->fail('请输入保障服务条款');
return app('json')->fail('请输入保障服务条款');
}
if (!$data['image']) return $this->fail('请上传图标');
if (!$data['image']) return app('json')->fail('请上传图标');
if ($this->services->getOne(['name' => $data['name']])) {
return $this->fail('保障服务条款已存在');
return app('json')->fail('保障服务条款已存在');
}
$data['type'] = 2;
$data['relation_id'] = $this->supplierId;
$data['add_time'] = time();
$this->services->save($data);
return $this->success('添加保障服务成功!');
return app('json')->success('添加保障服务成功!');
}
/**
@ -110,7 +111,7 @@ class StoreProductEnsure extends AuthController
*/
public function edit($id)
{
return $this->success($this->services->editForm((int)$id));
return app('json')->success($this->services->editForm((int)$id));
}
/**
@ -127,15 +128,15 @@ class StoreProductEnsure extends AuthController
['sort', 0],
]);
if (!$data['name']) {
return $this->fail('请输入保障服务条款');
return app('json')->fail('请输入保障服务条款');
}
if (!$data['image']) return $this->fail('请上传图标');
if (!$data['image']) return app('json')->fail('请上传图标');
$cate = $this->services->getOne(['name' => $data['name']]);
if ($cate && $cate['id'] != $id) {
return $this->fail('保障服务条款已存在');
return app('json')->fail('保障服务条款已存在');
}
$this->services->update($id, $data);
return $this->success('修改成功!');
return app('json')->success('修改成功!');
}
/**
@ -146,12 +147,12 @@ class StoreProductEnsure extends AuthController
*/
public function set_show($id, $is_show)
{
($is_show == '' || $id == '') && $this->fail('缺少参数');
($is_show == '' || $id == '') && app('json')->fail('缺少参数');
$res = $this->services->update((int)$id, ['status' => (int)$is_show]);
if ($res) {
return $this->success('设置成功');
return app('json')->success('设置成功');
} else {
return $this->fail('设置失败');
return app('json')->fail('设置失败');
}
}
@ -163,9 +164,9 @@ class StoreProductEnsure extends AuthController
public function delete($id)
{
if (!$id || !$this->services->count(['id' => $id])) {
return $this->fail('删除的数据不存在');
return app('json')->fail('删除的数据不存在');
}
$this->services->delete((int)$id);
return $this->success('删除成功!');
return app('json')->success('删除成功!');
}
}

View File

@ -44,7 +44,7 @@ class StoreProductLabel extends AuthController
*/
public function tree_list()
{
return $this->success($this->services->getProductLabelTreeList());
return app('json')->success('',$this->services->getProductLabelTreeList());
}
/**
@ -53,7 +53,7 @@ class StoreProductLabel extends AuthController
*/
public function allLabel()
{
return $this->success($this->services->getList(2, (int)$this->supplierId));
return app('json')->success('',$this->services->getList(2, (int)$this->supplierId));
}
/**
@ -68,34 +68,21 @@ class StoreProductLabel extends AuthController
['label_cate', 0],
['label_name', ''],
]);
if (!$data['label_cate']) {
return $this->fail('请选择标签组');
}
if (!trim($data['label_name'])) {
return $this->fail('请输入标签名称');
}
if (!$data['label_cate']) return app('json')->fail('请选择标签组');
if (!trim($data['label_name'])) return app('json')->fail('请输入标签名称');
$label = $this->services->getOne(['label_cate' => $data['label_cate'], 'label_name' => $data['label_name'], 'type' => 2, 'relation_id' => $this->supplierId]);
if ($id) {
if ($label && $id != $label['id']) {
return $this->fail('标签已经存在');
}
if ($this->services->update($id, $data)) {
return $this->success('编辑成功');
} else {
return $this->fail('编辑失败');
}
if ($label && $id != $label['id']) return app('json')->fail('标签已经存在');
if ($this->services->update($id, $data)) return app('json')->success('编辑成功');
else return app('json')->fail('编辑失败');
} else {
if ($label) {
return $this->fail('标签已经存在');
}
if ($label) return app('json')->fail('标签已经存在');
$data['type'] = 2;
$data['relation_id'] = $this->supplierId;
$data['add_time'] = time();
if ($this->services->save($data)) {
return $this->success('保存成功');
} else {
return $this->fail('保存失败');
}
if ($this->services->save($data)) return app('json')->success('保存成功');
else return app('json')->fail('保存失败');
}
}
@ -108,10 +95,10 @@ class StoreProductLabel extends AuthController
public function delete($id)
{
if (!$id || !$this->services->count(['id' => $id])) {
return $this->fail('删除的数据不存在');
return app('json')->fail('删除的数据不存在');
}
$this->services->delete($id);
return $this->success('删除成功');
return app('json')->success('删除成功');
}
/**
@ -123,6 +110,6 @@ class StoreProductLabel extends AuthController
*/
public function getLabelForm()
{
return $this->success($this->services->getLabelForm());
return app('json')->success('',$this->services->getLabelForm());
}
}

View File

@ -53,7 +53,7 @@ class StoreProductLabelCate extends AuthController
$where['relation_id'] = $this->supplierId;
$where['group'] = 2;
$where['product_label'] = 1;
return $this->success($this->services->getProductLabelCateList($where));
return app('json')->success('',$this->services->getProductLabelCateList($where));
}
@ -64,7 +64,7 @@ class StoreProductLabelCate extends AuthController
*/
public function create()
{
return $this->success($this->services->createForm());
return app('json')->success('',$this->services->createForm());
}
/**
@ -78,17 +78,17 @@ class StoreProductLabelCate extends AuthController
['sort', 0],
]);
if (!trim($data['name'])) {
return $this->fail('请输入标签组名称');
return app('json')->fail('请输入标签组名称');
}
if ($this->services->getOne(['name' => $data['name'], 'group' => 2, 'type' => 2, 'relation_id' => $this->supplierId])) {
return $this->fail('标签组已存在');
return app('json')->fail('标签组已存在');
}
$data['type'] = 2;
$data['relation_id'] = $this->supplierId;
$data['group'] = 2;
$data['add_time'] = time();
$this->services->save($data);
return $this->success('添加标签组成功!');
return app('json')->success('添加标签组成功!');
}
/**
@ -99,7 +99,7 @@ class StoreProductLabelCate extends AuthController
*/
public function edit($id)
{
return $this->success($this->services->editForm((int)$id));
return app('json')->success('',$this->services->editForm((int)$id));
}
/**
@ -114,14 +114,14 @@ class StoreProductLabelCate extends AuthController
['sort', 0],
]);
if (!$data['name']) {
return $this->fail('请输入标签组名称');
return app('json')->fail('请输入标签组名称');
}
$cate = $this->services->getOne(['name' => $data['name'], 'group' => 2, 'type' => 2, 'relation_id' => $this->supplierId]);
if ($cate && $cate['id'] != $id) {
return $this->fail('标签组已存在');
return app('json')->fail('标签组已存在');
}
$this->services->update($id, $data);
return $this->success('修改成功!');
return app('json')->success('修改成功!');
}
/**
@ -133,12 +133,12 @@ class StoreProductLabelCate extends AuthController
public function delete(StoreProductLabelServices $labelServices, $id)
{
if (!$id || !$this->services->count(['id' => $id])) {
return $this->fail('删除的数据不存在');
return app('json')->fail('删除的数据不存在');
}
if ($labelServices->count(['label_cate' => $id])) {
return $this->fail('标签组下有标签不能删除');
return app('json')->fail('标签组下有标签不能删除');
}
$this->services->delete((int)$id);
return $this->success('删除成功!');
return app('json')->success('删除成功!');
}
}

View File

@ -45,7 +45,7 @@ class ShippingTemplates extends AuthController
]);
$where['type'] = 2;
$where['relation_id'] = $this->supplierId;
return $this->success($this->services->getShippingList($where));
return app('json')->success('',$this->services->getShippingList($where));
}
/**
@ -55,7 +55,7 @@ class ShippingTemplates extends AuthController
*/
public function edit($id)
{
return $this->success($this->services->getShipping((int)$id));
return app('json')->success('',$this->services->getShipping((int)$id));
}
/**
@ -85,7 +85,7 @@ class ShippingTemplates extends AuthController
$temp['add_time'] = time();
$this->services->save((int)$id, $temp, $data);
event('product.shipping.update');
return $this->success((int)$id ? '修改成功!' : '添加成功!');
return app('json')->success((int)$id ? '修改成功!' : '添加成功!');
}
/**
@ -97,11 +97,11 @@ class ShippingTemplates extends AuthController
[['id', 'd'], 0],
], true);
if ($id == 1) {
return $this->fail('默认模板不能删除');
return app('json')->fail('默认模板不能删除');
} else {
$this->services->detete($id);
event('product.shipping.update');
return $this->success('删除成功');
return app('json')->success('删除成功');
}
}
@ -114,6 +114,6 @@ class ShippingTemplates extends AuthController
*/
public function city_list(SystemCityServices $services)
{
return $this->success($services->getShippingCity());
return app('json')->success('',$services->getShippingCity());
}
}

View File

@ -53,7 +53,7 @@ class StoreProductSpecs extends AuthController
$where = $request->postMore([
['name', '']
]);
return $this->success($this->templateServices->getProductSpecsTemplateList($where, 2, (int)$this->supplierId));
return app('json')->success($this->templateServices->getProductSpecsTemplateList($where, 2, (int)$this->supplierId));
}
/**
@ -63,7 +63,7 @@ class StoreProductSpecs extends AuthController
*/
public function allSpecs(Request $request)
{
return $this->success($this->templateServices->getAllSpecs(2, (int)$this->supplierId));
return app('json')->success($this->templateServices->getAllSpecs(2, (int)$this->supplierId));
}
/**
@ -73,12 +73,12 @@ class StoreProductSpecs extends AuthController
*/
public function getInfo($id)
{
if (!$id) return $this->fail('缺少参数ID');
if (!$id) return app('json')->fail('缺少参数ID');
$temp = $this->templateServices->get(['id' => $id, 'group' => 3], ['*'], ['specs']);
if (!$temp) {
return $this->fail('参数模版不存在');
return app('json')->fail('参数模版不存在');
}
return $this->success($temp->toArray());
return app('json')->success($temp->toArray());
}
@ -96,7 +96,7 @@ class StoreProductSpecs extends AuthController
['sort', ''],
]);
if (!$data['name']) {
return $this->fail('请输入参数模版名称');
return app('json')->fail('请输入参数模版名称');
}
$specs = $data['specs'];
unset($data['specs']);
@ -105,20 +105,20 @@ class StoreProductSpecs extends AuthController
$temp = $this->templateServices->getOne(['name' => $data['name'], 'group' => 3, 'type' => $type, 'relation_id' => $supplier_id]);
if ($id) {
if ($temp && $id != $temp['id']) {
return $this->fail('参数模版已经存在');
return app('json')->fail('参数模版已经存在');
}
$this->templateServices->transaction(function () use ($id, $data, $specs, $type, $supplier_id) {
if (!$this->templateServices->update($id, $data)) {
return $this->success('编辑失败');
return app('json')->success('编辑失败');
}
if (!$this->services->updateData($id, $specs)) {
return $this->success('编辑失败');
return app('json')->success('编辑失败');
}
});
return $this->success('编辑成功');
return app('json')->success('编辑成功');
} else {
if ($temp) {
return $this->fail('参数模版已经存在');
return app('json')->fail('参数模版已经存在');
}
$data['type'] = $type;
$data['relation_id'] = $supplier_id;
@ -126,13 +126,13 @@ class StoreProductSpecs extends AuthController
$data['add_time'] = time();
$this->templateServices->transaction(function () use ($id, $data, $specs, $type, $supplier_id) {
if (!$res = $this->templateServices->save($data)) {
return $this->success('保存失败');
return app('json')->success('保存失败');
}
if (!$this->services->saveData((int)$res->id, $specs, $type, $supplier_id)) {
return $this->success('保存失败');
return app('json')->success('保存失败');
}
});
return $this->success('保存成功');
return app('json')->success('保存成功');
}
}
@ -145,10 +145,10 @@ class StoreProductSpecs extends AuthController
public function delete($id)
{
if (!$id || !($this->templateServices->count(['id' => $id]))) {
return $this->fail('删除的数据不存在');
return app('json')->fail('删除的数据不存在');
}
$this->templateServices->delete($id);
$this->services->delete(['temp_id' => $id]);
return $this->success('删除成功');
return app('json')->success('删除成功');
}
}

View File

@ -64,7 +64,7 @@ class Queue extends AuthController
/** @var QueueAuxiliaryServices $auxiliaryService */
$auxiliaryService = app()->make(QueueAuxiliaryServices::class);
$data = $auxiliaryService->deliveryLogList(['binding_id' => $id, 'type' => $type]);
return $this->success($data);
return app('json')->success($data);
}
/**
@ -78,9 +78,9 @@ class Queue extends AuthController
*/
public function again_do_queue($id, $type)
{
if (!$id || !$type) return $this->fail("参数缺失");
if (!$id || !$type) return app('json')->fail("参数缺失");
$this->services->againDoQueue($id, $type);
return $this->success("后台程序已再次执行此批量任务");
return app('json')->success("后台程序已再次执行此批量任务");
}
/**
@ -94,9 +94,9 @@ class Queue extends AuthController
*/
public function del_wrong_queue($id, $type)
{
if (!$id || !$type) return $this->fail("参数缺失");
if (!$id || !$type) return app('json')->fail("参数缺失");
$res = $this->services->delWrongQueue($id, $type);
return $this->success($res ? "异常任务清除成功" : "数据无异常");
return app('json')->success($res ? "异常任务清除成功" : "数据无异常");
}
@ -110,10 +110,10 @@ class Queue extends AuthController
*/
public function stop_wrong_queue($id)
{
if (!$id) return $this->fail("参数缺失");
if (!$id) return app('json')->fail("参数缺失");
$queueInfo = $this->services->getQueueOne(['id' => $id]);
if (!$queueInfo) $this->fail('任务不存在');
if (!$queueInfo) app('json')->fail('任务不存在');
$this->services->delWrongQueue($id, $queueInfo['type'], false);
return $this->success("任务停止成功");
return app('json')->success("任务停止成功");
}
}

View File

@ -46,9 +46,9 @@ class Config extends AuthController
public function getConfig($type, StoreConfigServices $services)
{
if (!isset(StoreConfigServices::CONFIG_TYPE[$type])) {
return $this->fail('类型不正确');
return app('json')->fail('类型不正确');
}
return $this->success($services->getConfigAll(StoreConfigServices::CONFIG_TYPE[$type], 2, (int)$this->supplierId));
return app('json')->success('',$services->getConfigAll(StoreConfigServices::CONFIG_TYPE[$type], 2, (int)$this->supplierId));
}
/**
@ -61,7 +61,7 @@ class Config extends AuthController
$data = $this->request->post();
$services->saveConfig($data,2, (int)$this->supplierId);
\crmeb\services\SystemConfigService::clear();
return $this->success('修改成功');
return app('json')->success('修改成功');
}
/**
@ -77,10 +77,10 @@ class Config extends AuthController
{
$name = $this->request->param('name', '');
if (!$name) {
return $this->fail('参数错误');
return app('json')->fail('参数错误');
}
$supplier_id = (int)$this->supplierId;
return $this->success($services->getFormBuildRule($name, 2, $supplier_id));
return app('json')->success('',$services->getFormBuildRule($name, 2, $supplier_id));
}
@ -91,6 +91,6 @@ class Config extends AuthController
public function getFormBuild(StoreConfigServices $services, string $type)
{
$supplier_id = (int)$this->supplierId;
return $this->success($services->getFormBuildRule($type, 2, $supplier_id));
return app('json')->success('',$services->getFormBuildRule($type, 2, $supplier_id));
}
}

View File

@ -42,7 +42,7 @@ class Supplier extends AuthController
public function read()
{
$info = $this->services->getSupplierInfo((int)$this->supplierId);
return $this->success($info->toArray());
return app('json')->success('',$info->toArray());
}
/**
@ -68,7 +68,7 @@ class Supplier extends AuthController
$data['address'] = str_replace([' ', '/', '\\'], '', $data['address']);
$data['detailed_address'] = str_replace([' ', '/', '\\'], '', $data['detailed_address']);
$this->services->update((int)$this->supplierId, $data);
return $this->success('保存成功');
return app('json')->success('保存成功');
}
/**

View File

@ -58,7 +58,7 @@ class SupplierAdmin extends AuthController
'relation_id' => $this->supplierId,
'level' => 1
];
return $this->success($this->adminServices->getAdminList($where));
return app('json')->success('',$this->adminServices->getAdminList($where));
}
/**
@ -68,7 +68,7 @@ class SupplierAdmin extends AuthController
*/
public function create()
{
return $this->success($this->adminServices->createForm(0, '/admin'));
return app('json')->success('',$this->adminServices->createForm(0, '/admin'));
}
/**
@ -93,9 +93,9 @@ class SupplierAdmin extends AuthController
$data['admin_type'] = 4;
$data['relation_id'] = $this->supplierId;
if ($this->adminServices->create($data)) {
return $this->success('添加成功');
return app('json')->success('添加成功');
} else {
return $this->fail('添加失败');
return app('json')->fail('添加失败');
}
}
@ -108,9 +108,9 @@ class SupplierAdmin extends AuthController
public function edit(int $id)
{
if (!$id) {
return $this->fail('管理员信息读取失败');
return app('json')->fail('管理员信息读取失败');
}
return $this->success($this->adminServices->updateForm(0, (int)$id, '/admin/'));
return app('json')->success('',$this->adminServices->updateForm(0, (int)$id, '/admin/'));
}
/**
@ -134,9 +134,9 @@ class SupplierAdmin extends AuthController
$this->validate($data, \app\validate\admin\setting\SystemAdminValidate::class, 'supplier_update');
if ($this->adminServices->save($id, $data)) {
return $this->success('修改成功');
return app('json')->success('修改成功');
} else {
return $this->fail('修改失败');
return app('json')->fail('修改失败');
}
}
@ -149,9 +149,9 @@ class SupplierAdmin extends AuthController
{
$info = $this->adminServices->get($id);
if (!$info) {
return $this->fail('获取失败');
return app('json')->fail('获取失败');
}
return $this->success($info->toArray());
return app('json')->success('',$info->toArray());
}
/**
@ -162,13 +162,13 @@ class SupplierAdmin extends AuthController
public function delete(int $id)
{
if (!$id) {
return $this->fail('删除失败,缺少参数');
return app('json')->fail('删除失败,缺少参数');
}
if ($this->adminServices->update($id, ['is_del' => 1, 'status' => 0])) {
return $this->success('删除成功!');
return app('json')->success('删除成功!');
} else {
return $this->fail('删除失败');
return app('json')->fail('删除失败');
}
}
@ -181,6 +181,6 @@ class SupplierAdmin extends AuthController
public function set_status($id, $status)
{
$this->adminServices->update((int)$id, ['status' => $status]);
return $this->success($status == 0 ? '关闭成功' : '开启成功');
return app('json')->success($status == 0 ? '关闭成功' : '开启成功');
}
}

View File

@ -41,7 +41,7 @@ class SupplierTicketPrint extends AuthController
*/
public function read()
{
return $this->success($this->services->getTicketInfo((int)$this->supplierId));
return app('json')->success('',$this->services->getTicketInfo((int)$this->supplierId));
}
/**
@ -61,6 +61,6 @@ class SupplierTicketPrint extends AuthController
$this->validate($data, \app\validate\supplier\SupplierTicketPrintValidate::class, 'update');
$this->services->savePrintData((int)$this->supplierId, $data);
return $this->success('保存成功');
return app('json')->success('保存成功');
}
}

View File

@ -42,7 +42,7 @@ class SystemForm extends AuthController
public function allSystemForm()
{
$data = $this->services->getFormList([], ['id', 'name']);
return $this->success($data['list'] ?? []);
return app('json')->success($data['list'] ?? []);
}
/**
@ -52,7 +52,7 @@ class SystemForm extends AuthController
*/
public function getInfo(int $id)
{
if (!$id) return $this->fail('数据不存在');
if (!$id) return app('json')->fail('数据不存在');
[$type] = $this->request->postMore([
['type', 0],
], true);
@ -60,14 +60,14 @@ class SystemForm extends AuthController
if ($info) {
$info = $info->toArray();
} else {
return $this->fail('数据不存在');
return app('json')->fail('数据不存在');
}
$info['value'] = json_decode($info['value'], true);
if ($type == 1) {//处理表单数据
$value = $info['value'] ?? [];
$info = $this->services->handleForm($value);
}
return $this->success(compact('info'));
return app('json')->success(compact('info'));
}

View File

@ -40,7 +40,7 @@ class User extends AuthController
if (is_string($id)) {
$id = (int)$id;
}
return $this->success($this->services->read($id));
return app('json')->success('',$this->services->read($id));
}
/**
@ -54,8 +54,8 @@ class User extends AuthController
['type', ''],
]);
$id = (int)$id;
if ($data['type'] == '') return $this->fail('缺少参数');
return $this->success($this->services->oneUserInfo($id, $data['type']));
if ($data['type'] == '') return app('json')->fail('缺少参数');
return app('json')->success('',$this->services->oneUserInfo($id, $data['type']));
}
/**
@ -71,7 +71,7 @@ class User extends AuthController
{
$where['uid'] = (int)$id;
$where['type'] = 'visit';
return app('json')->success($services->getList($where, 'product_id'));
return app('json')->success('',$services->getList($where, 'product_id'));
}
/**
@ -88,6 +88,6 @@ class User extends AuthController
$where['store_id'] = 0;
$where['staff_id'] = 0;
$where['uid'] = $id;
return app('json')->success($services->getSpreadList($where, '*', ['spreadUser', 'admin'], false));
return app('json')->success('',$services->getSpreadList($where, '*', ['spreadUser', 'admin'], false));
}
}

View File

@ -144,15 +144,13 @@ class StoreBrandServices extends BaseServices
public function cascaderList($type = 1)
{
$where = [];
if ($type == 1) {
$top = true;
} else {
$top = false;
}
if ($type == 1) $top = true;
else $top = false;
$menus = [];
$where['is_del'] = 0;
$where['is_show'] = 1;
$list = get_tree_children($this->dao->getList($where, [], ['id as value', 'brand_name as label', 'pid']), 'children', 'value');
$list = $this->dao->getList($where, [], ['brand_id as value', 'brand_name as label']);
// $list = $this->get_tree_children($brandList, 'children', 'value');
if ($top) {
$menus = [['value' => 0, 'label' => '顶级品牌']];
foreach ($list as &$item) {

View File

@ -115,7 +115,9 @@ class StoreProductCategoryServices extends BaseServices
{
$where = ['is_show' => 1, 'type' => $type, 'relation_id' => $relation_id];
if ($isPid) $where['pid'] = 0;
$data = get_tree_children($this->dao->getTierList($where, ['id as value', 'cate_name as label', 'pid']), 'children', 'value');
$data = $this->dao->getTierList($where, ['id as value', 'cate_name as label', 'pid']);
// $data = get_tree_children($list, 'children', 'value');
return $data;
}