zengyyh 4 months ago
parent 9d2a1422aa
commit 52e8b7baa9
  1. 53
      app/admin/controller/RetailDescribe.php
  2. 6
      app/api/controller/Retail.php
  3. 44
      app/store/controller/Controller.php
  4. 40
      app/store/model/RetailDescribe.php

@ -0,0 +1,53 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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() ?: '删除失败');
}
}

@ -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'));
}

@ -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']<time()){
throwError('很抱歉,当前商城已过期');
}
$this->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']<time()){
// throwError('很抱歉,当前商城已过期');
// }
// $this->storeInfo = $store;
// }
}

@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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();
}
}
Loading…
Cancel
Save