diff --git a/app/admin/controller/RetailDescribe.php b/app/admin/controller/RetailDescribe.php new file mode 100644 index 00000000..e8e9786f --- /dev/null +++ b/app/admin/controller/RetailDescribe.php @@ -0,0 +1,53 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\admin\controller; +use app\store\model\RetailDescribe as retDescribeModel; + +class RetailDescribe extends Controller +{ + public function index() + { + $model = new retDescribeModel; + $list = $model->getAll(); + $grouped = []; + foreach ($list as $item) { + $grouped[$item['plate_id']][] = $item; + } + return $this->renderSuccess(compact('grouped')); + } + + public function add(){ + $model = new retDescribeModel; + if($model->add($this->postData())){ + return $this->renderSuccess('添加成功'); + } + return $this->renderError($model->getError() ?: '添加失败'); + } + + public function edit(int $id){ + $model = new retDescribeModel; + if($model->edit($id,$this->postForm())){ + return $this->renderSuccess('编辑成功'); + } + return $this->renderError($model->getError() ?: '编辑失败'); + } + + public function delete(array $id){ + $model = new retDescribeModel; + if($model->del($id)){ + return $this->renderSuccess('删除成功'); + } + return $this->renderError($model->getError() ?: '删除失败'); + } + +} \ No newline at end of file diff --git a/app/api/controller/Retail.php b/app/api/controller/Retail.php index 74227634..59309a71 100644 --- a/app/api/controller/Retail.php +++ b/app/api/controller/Retail.php @@ -96,7 +96,11 @@ class Retail extends Controller public function describe() { $list = RetailDescribeModel::withoutGlobalScope()->select(); - return $this->renderSuccess(compact('list')); + $grouped = []; + foreach ($list as $item) { + $grouped[$item['plate_id']][] = $item; + } + return $this->renderSuccess(compact('grouped')); } diff --git a/app/store/controller/Controller.php b/app/store/controller/Controller.php index c21caeff..01014260 100644 --- a/app/store/controller/Controller.php +++ b/app/store/controller/Controller.php @@ -33,7 +33,7 @@ class Controller extends BaseController // 当前商城ID protected int $storeId; - protected $storeInfo; + // protected $storeInfo; // 当前商户ID protected int $merchantId = 0; @@ -88,7 +88,7 @@ class Controller extends BaseController $this->getMerchantId(); // 验证当前商城状态 - $this->checkStore(); + // $this->checkStore(); } /** @@ -194,26 +194,26 @@ class Controller extends BaseController throwError('illegal request method'); } - /** - * 验证当前商城状态 - * @return void - * @throws BaseException - */ - private function checkStore(): void - { - // 获取当前商城信息 - $store = StoreModel::detail($this->storeId); - if (empty($store)) { - throwError('很抱歉,当前商城信息不存在'); - } - if ($store['is_recycle'] || $store['is_delete']) { - throwError('很抱歉,当前商城已删除'); - } - if($store['effective_time']storeInfo = $store; - } + // /** + // * 验证当前商城状态 + // * @return void + // * @throws BaseException + // */ + // private function checkStore(): void + // { + // // 获取当前商城信息 + // $store = StoreModel::detail($this->storeId); + // if (empty($store)) { + // throwError('很抱歉,当前商城信息不存在'); + // } + // if ($store['is_recycle'] || $store['is_delete']) { + // throwError('很抱歉,当前商城已删除'); + // } + // if($store['effective_time']storeInfo = $store; + // } } diff --git a/app/store/model/RetailDescribe.php b/app/store/model/RetailDescribe.php new file mode 100644 index 00000000..ff50296a --- /dev/null +++ b/app/store/model/RetailDescribe.php @@ -0,0 +1,40 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\store\model; + +use app\common\model\RetailDescribe as retDescribeModel; + +class RetailDescribe extends RetDescribeModel +{ + + public function getAll() + { + + return self::select(); + } + + public function detail(int $id){ + return self::where('id',$id)->find(); + } + + public function add(array $data){ + return $this->save($data); + } + public function edit(int $id ,array $data){ + return $this->where('id' ,$id)->update($data); + } + + public function del(array $id){ + return $this->whereIn('id' ,$id)->delete(); + } +} \ No newline at end of file