parent
a658b82f5a
commit
4d914ed097
@ -0,0 +1,82 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\api\controller; |
||||||
|
|
||||||
|
use app\common\model\store\StoreSettle; |
||||||
|
use app\api\service\User as UserService; |
||||||
|
use think\response\Json; |
||||||
|
use app\api\model\Feedback as feedbackModel; |
||||||
|
use app\common\model\UploadFile; |
||||||
|
use app\common\model\Channel; |
||||||
|
|
||||||
|
/** |
||||||
|
* 意见反馈 |
||||||
|
* Class Store |
||||||
|
* @package app\store\controller |
||||||
|
*/ |
||||||
|
class Feedback extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @notes:新增文章 |
||||||
|
* @return Json |
||||||
|
* @throws BaseException |
||||||
|
* @author: wanghousheng |
||||||
|
*/ |
||||||
|
public function add(): Json |
||||||
|
{ |
||||||
|
if (!UserService::isStore()) { |
||||||
|
throwError("无权限", 403); |
||||||
|
} |
||||||
|
|
||||||
|
$useInfo = UserService::getCurrentLoginUser(true); |
||||||
|
|
||||||
|
$content = $this->request->post('content'); |
||||||
|
if (!$content) { |
||||||
|
return $this->renderError('内容不能为空'); |
||||||
|
} |
||||||
|
$cate = intval($this->request->post('cate')); |
||||||
|
if (!$cate) { |
||||||
|
return $this->renderError('分类不能为空'); |
||||||
|
} |
||||||
|
|
||||||
|
$data = $this->postForm(); |
||||||
|
$data['merchant_id'] = $this->merchantId; |
||||||
|
if ((new squareModel)->add($data)) { |
||||||
|
return $this->renderSuccess('添加成功'); |
||||||
|
} |
||||||
|
return $this->renderError('添加失败'); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 列表 |
||||||
|
*/ |
||||||
|
public function list(): Json { |
||||||
|
$model = new feedbackModel; |
||||||
|
|
||||||
|
$params = $this->request->param(); |
||||||
|
$list = $model->getList($params)->toArray(); |
||||||
|
|
||||||
|
foreach ($list['data'] as $kr => $r) { |
||||||
|
$res[$kr]['imgs'] = []; |
||||||
|
if ($r['imgs']) { |
||||||
|
$img_ids = explode(",", $r['imgs']); |
||||||
|
$files = UploadFile::getFileList($img_ids); |
||||||
|
$list['data'][$kr]['imgs'] = $files ?: null; |
||||||
|
} |
||||||
|
} |
||||||
|
return $this->renderSuccess($list); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,102 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\api\controller; |
||||||
|
|
||||||
|
use app\common\model\store\StoreSettle; |
||||||
|
use app\api\service\User as UserService; |
||||||
|
use think\response\Json; |
||||||
|
use app\api\model\Square as squareModel; |
||||||
|
use app\api\model\Squarelike as squarelikeModel; |
||||||
|
use app\common\model\UploadFile; |
||||||
|
use app\common\model\Channel; |
||||||
|
|
||||||
|
/** |
||||||
|
* 广场动态 |
||||||
|
* Class Store |
||||||
|
* @package app\store\controller |
||||||
|
*/ |
||||||
|
class Square extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @notes:新增文章 |
||||||
|
* @return Json |
||||||
|
* @throws BaseException |
||||||
|
* @author: wanghousheng |
||||||
|
*/ |
||||||
|
public function add(): Json |
||||||
|
{ |
||||||
|
if (!UserService::isStore()) { |
||||||
|
throwError("无权限", 403); |
||||||
|
} |
||||||
|
|
||||||
|
$useInfo = UserService::getCurrentLoginUser(true); |
||||||
|
|
||||||
|
$content = $this->request->post('content'); |
||||||
|
if (!$content) { |
||||||
|
return $this->renderError('内容不能为空'); |
||||||
|
} |
||||||
|
$cate = intval($this->request->post('cate')); |
||||||
|
if (!$cate) { |
||||||
|
return $this->renderError('分类不能为空'); |
||||||
|
} |
||||||
|
|
||||||
|
$data = $this->postForm(); |
||||||
|
$data['merchant_id'] = $this->merchantId; |
||||||
|
if ((new squareModel)->add($data)) { |
||||||
|
return $this->renderSuccess('添加成功'); |
||||||
|
} |
||||||
|
return $this->renderError('添加失败'); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 列表 |
||||||
|
*/ |
||||||
|
public function list(): Json { |
||||||
|
$model = new squareModel; |
||||||
|
$list = $model->getList($this->request->param())->toArray(); |
||||||
|
|
||||||
|
foreach ($list['data'] as $kr => $r) { |
||||||
|
$res[$kr]['imgs'] = []; |
||||||
|
if ($r['imgs']) { |
||||||
|
$img_ids = explode(",", $r['imgs']); |
||||||
|
$files = UploadFile::getFileList($img_ids); |
||||||
|
$list['data'][$kr]['imgs'] = $files ?: null; |
||||||
|
} |
||||||
|
} |
||||||
|
return $this->renderSuccess($list); |
||||||
|
} |
||||||
|
|
||||||
|
public function dynamicLike(int $id): Json |
||||||
|
{ |
||||||
|
if (!UserService::isStore()) { |
||||||
|
throwError("无权限", 403); |
||||||
|
} |
||||||
|
$useInfo = UserService::getCurrentLoginUser(true); |
||||||
|
|
||||||
|
$model = new squarelikeModel; |
||||||
|
$detail = squarelikeModel::detail($id, $useInfo['data']['user_name']); |
||||||
|
$data = $this->postForm(); |
||||||
|
if (empty($detail)) { |
||||||
|
if ($model->add($data)) { |
||||||
|
return $this->renderSuccess('操作成功'); |
||||||
|
} |
||||||
|
} else { |
||||||
|
$data['squarelike_id'] = $detail['squarelike_id']; |
||||||
|
if ($detail->delete($data)) { |
||||||
|
return $this->renderSuccess('操作成功'); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\api\model; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Class Store |
||||||
|
* @package app\store\model |
||||||
|
*/ |
||||||
|
class Feedback extends \app\common\model\Feedback |
||||||
|
{ |
||||||
|
/** |
||||||
|
* 更新记录 |
||||||
|
* @param array $data |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function edit(array $data): bool |
||||||
|
{ |
||||||
|
// 是否删除图片 |
||||||
|
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0; |
||||||
|
return $this->save($data) !== false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增记录 |
||||||
|
* @param array $data |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function add(array $data): bool |
||||||
|
{ |
||||||
|
return $this->save($this->createData($data)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建数据 |
||||||
|
* @param array $data |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
private function createData(array $data): array |
||||||
|
{ |
||||||
|
$data['store_id'] = self::$storeId; |
||||||
|
return $data; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 软删除 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function setDelete(): bool |
||||||
|
{ |
||||||
|
return $this->save(['is_delete' => 1]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\api\model; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Class Store |
||||||
|
* @package app\store\model |
||||||
|
*/ |
||||||
|
class Square extends \app\common\model\Square |
||||||
|
{ |
||||||
|
/** |
||||||
|
* 更新记录 |
||||||
|
* @param array $data |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function edit(array $data): bool |
||||||
|
{ |
||||||
|
// 是否删除图片 |
||||||
|
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0; |
||||||
|
return $this->save($data) !== false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增记录 |
||||||
|
* @param array $data |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function add(array $data): bool |
||||||
|
{ |
||||||
|
return $this->save($this->createData($data)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建数据 |
||||||
|
* @param array $data |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
private function createData(array $data): array |
||||||
|
{ |
||||||
|
$data['store_id'] = self::$storeId; |
||||||
|
return $data; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 软删除 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function setDelete(): bool |
||||||
|
{ |
||||||
|
return $this->save(['is_delete' => 1]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\api\model; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* Class Store |
||||||
|
* @package app\store\model |
||||||
|
*/ |
||||||
|
class Squarelike extends \app\common\model\Squarelike |
||||||
|
{ |
||||||
|
/** |
||||||
|
* 更新记录 |
||||||
|
* @param array $data |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function edit(array $data): bool |
||||||
|
{ |
||||||
|
return $this->save($data) !== false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 新增记录 |
||||||
|
* @param array $data |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function add(array $data): bool |
||||||
|
{ |
||||||
|
return $this->save($this->createData($data)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建数据 |
||||||
|
* @param array $data |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
private function createData(array $data): array |
||||||
|
{ |
||||||
|
$data['store_id'] = self::$storeId; |
||||||
|
return $data; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 软删除 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function setDelete(): bool |
||||||
|
{ |
||||||
|
return $this->save(['is_delete' => 1]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\common\model; |
||||||
|
|
||||||
|
use cores\BaseModel; |
||||||
|
use think\model\relation\HasOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 商家记录表模型 |
||||||
|
* Class Store |
||||||
|
* @package app\common\model |
||||||
|
*/ |
||||||
|
class Feedback extends BaseModel |
||||||
|
{ |
||||||
|
// 定义表名 |
||||||
|
protected $name = 'feedback'; |
||||||
|
|
||||||
|
// 定义主键 |
||||||
|
protected $pk = 'feedback_id'; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 详情信息 |
||||||
|
* @param int $storeId |
||||||
|
* @return static|array|null |
||||||
|
*/ |
||||||
|
public static function detail(int $merchantId) |
||||||
|
{ |
||||||
|
$where = [ |
||||||
|
'merchant_id' => $merchantId, |
||||||
|
'store_id' => self::$storeId |
||||||
|
]; |
||||||
|
return static::get($where, []); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取列表数据 |
||||||
|
* @param bool $isRecycle 是否在回收站 |
||||||
|
* @return \think\Paginator |
||||||
|
* @throws \think\db\exception\DbException |
||||||
|
*/ |
||||||
|
public function getList(array $param = [], int $pageSize = 15): \think\Paginator |
||||||
|
{ |
||||||
|
$res = $this->where($this->getFilter($param)) |
||||||
|
->where('is_delete', '=', 0) |
||||||
|
->order(['create_time' => 'desc', $this->getPk()]) |
||||||
|
->paginate($pageSize); |
||||||
|
|
||||||
|
return $res; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置列表查询条件 |
||||||
|
* @param array $param |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
private function getFilter(array $param = []): array |
||||||
|
{ |
||||||
|
// 默认查询参数 |
||||||
|
$params = $this->setQueryDefaultValue($param, [ |
||||||
|
'search' => '', // 搜索关键词: 门店名称/联系人/电话 |
||||||
|
]); |
||||||
|
// 检索查询条件 |
||||||
|
$filter = []; |
||||||
|
// 搜索关键词 |
||||||
|
!empty($params['cate']) && $filter[] = ['cate', '=', $params['cate']]; |
||||||
|
|
||||||
|
!empty($params['userName']) && $filter[] = ['user_name', '=', $params['userName']]; |
||||||
|
|
||||||
|
// 门店状态 |
||||||
|
//is_numeric($params['status']) && $filter[] = ['status', '=', (int)$params['status']]; |
||||||
|
return $filter; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 软删除 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function setDelete(): bool |
||||||
|
{ |
||||||
|
return $this->save(['is_delete' => 1]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,90 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\common\model; |
||||||
|
|
||||||
|
use cores\BaseModel; |
||||||
|
use think\model\relation\HasOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 商家记录表模型 |
||||||
|
* Class Store |
||||||
|
* @package app\common\model |
||||||
|
*/ |
||||||
|
class Square extends BaseModel |
||||||
|
{ |
||||||
|
// 定义表名 |
||||||
|
protected $name = 'square'; |
||||||
|
|
||||||
|
// 定义主键 |
||||||
|
protected $pk = 'square_id'; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 详情信息 |
||||||
|
* @param int $storeId |
||||||
|
* @return static|array|null |
||||||
|
*/ |
||||||
|
public static function detail(int $merchantId) |
||||||
|
{ |
||||||
|
$where = [ |
||||||
|
'merchant_id' => $merchantId, |
||||||
|
'store_id' => self::$storeId |
||||||
|
]; |
||||||
|
return static::get($where, []); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取列表数据 |
||||||
|
* @param bool $isRecycle 是否在回收站 |
||||||
|
* @return \think\Paginator |
||||||
|
* @throws \think\db\exception\DbException |
||||||
|
*/ |
||||||
|
public function getList(array $param = [], int $pageSize = 15): \think\Paginator |
||||||
|
{ |
||||||
|
$res = $this->where($this->getFilter($param)) |
||||||
|
->where('is_delete', '=', 0) |
||||||
|
->order(['create_time' => 'desc', $this->getPk()]) |
||||||
|
->paginate($pageSize); |
||||||
|
|
||||||
|
return $res; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置列表查询条件 |
||||||
|
* @param array $param |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
private function getFilter(array $param = []): array |
||||||
|
{ |
||||||
|
// 默认查询参数 |
||||||
|
$params = $this->setQueryDefaultValue($param, [ |
||||||
|
'search' => '', // 搜索关键词: 门店名称/联系人/电话 |
||||||
|
]); |
||||||
|
// 检索查询条件 |
||||||
|
$filter = []; |
||||||
|
// 搜索关键词 |
||||||
|
!empty($params['cate']) && $filter[] = ['cate', '=', "%{$params['cate']}%"]; |
||||||
|
// 门店状态 |
||||||
|
//is_numeric($params['status']) && $filter[] = ['status', '=', (int)$params['status']]; |
||||||
|
return $filter; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 软删除 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function setDelete(): bool |
||||||
|
{ |
||||||
|
return $this->save(['is_delete' => 1]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
<?php |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
// | Author: 萤火科技 <admin@yiovo.com> |
||||||
|
// +---------------------------------------------------------------------- |
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\common\model; |
||||||
|
|
||||||
|
use cores\BaseModel; |
||||||
|
use think\model\relation\HasOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 商家记录表模型 |
||||||
|
* Class Store |
||||||
|
* @package app\common\model |
||||||
|
*/ |
||||||
|
class Squarelike extends BaseModel |
||||||
|
{ |
||||||
|
// 定义表名 |
||||||
|
protected $name = 'square'; |
||||||
|
|
||||||
|
// 定义主键 |
||||||
|
protected $pk = 'square_id'; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 详情信息 |
||||||
|
* @param int $storeId |
||||||
|
* @return static|array|null |
||||||
|
*/ |
||||||
|
public static function detail(int $id, String $userName) |
||||||
|
{ |
||||||
|
$where = [ |
||||||
|
'square_id' => $id, |
||||||
|
'user_name' => $userName, |
||||||
|
'store_id' => self::$storeId |
||||||
|
]; |
||||||
|
return static::get($where, []); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取列表数据 |
||||||
|
* @param bool $isRecycle 是否在回收站 |
||||||
|
* @return \think\Paginator |
||||||
|
* @throws \think\db\exception\DbException |
||||||
|
*/ |
||||||
|
public function getList(array $param = [], int $pageSize = 15): \think\Paginator |
||||||
|
{ |
||||||
|
$res = $this->where($this->getFilter($param)) |
||||||
|
->where('is_delete', '=', 0) |
||||||
|
->order(['create_time' => 'desc', $this->getPk()]) |
||||||
|
->paginate($pageSize); |
||||||
|
|
||||||
|
return $res; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置列表查询条件 |
||||||
|
* @param array $param |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
private function getFilter(array $param = []): array |
||||||
|
{ |
||||||
|
// 默认查询参数 |
||||||
|
$params = $this->setQueryDefaultValue($param, [ |
||||||
|
'search' => '', // 搜索关键词: 门店名称/联系人/电话 |
||||||
|
]); |
||||||
|
// 检索查询条件 |
||||||
|
$filter = []; |
||||||
|
// 搜索关键词 |
||||||
|
!empty($params['cate']) && $filter[] = ['cate', '=', "%{$params['cate']}%"]; |
||||||
|
// 门店状态 |
||||||
|
//is_numeric($params['status']) && $filter[] = ['status', '=', (int)$params['status']]; |
||||||
|
return $filter; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 软删除 |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function setDelete(): bool |
||||||
|
{ |
||||||
|
return $this->save(['is_delete' => 1]); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue