This commit is contained in:
mkm 2024-05-31 16:20:06 +08:00
parent 37fa6d93c6
commit def871cdb5
9 changed files with 706 additions and 0 deletions

View File

@ -0,0 +1,95 @@
<?php
namespace app\admin\controller\store_order;
use app\admin\controller\BaseAdminController;
use app\admin\lists\store_order\StoreOrderLists;
use app\admin\logic\store_order\StoreOrderLogic;
use app\admin\validate\store_order\StoreOrderValidate;
/**
* 订单列表控制器
* Class StoreOrderController
* @package app\admin\controller\store_order
*/
class StoreOrderController extends BaseAdminController
{
/**
* @notes 获取订单列表列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 16:02
*/
public function lists()
{
return $this->dataLists(new StoreOrderLists());
}
/**
* @notes 添加订单列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 16:02
*/
public function add()
{
$params = (new StoreOrderValidate())->post()->goCheck('add');
$result = StoreOrderLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(StoreOrderLogic::getError());
}
/**
* @notes 编辑订单列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 16:02
*/
public function edit()
{
$params = (new StoreOrderValidate())->post()->goCheck('edit');
$result = StoreOrderLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(StoreOrderLogic::getError());
}
/**
* @notes 删除订单列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 16:02
*/
public function delete()
{
$params = (new StoreOrderValidate())->post()->goCheck('delete');
StoreOrderLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取订单列表详情
* @return \think\response\Json
* @author admin
* @date 2024/05/31 16:02
*/
public function detail()
{
$params = (new StoreOrderValidate())->goCheck('detail');
$result = StoreOrderLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,95 @@
<?php
namespace app\admin\controller\store_product_unit;
use app\admin\controller\BaseAdminController;
use app\admin\lists\store_product_unit\StoreProductUnitLists;
use app\admin\logic\store_product_unit\StoreProductUnitLogic;
use app\admin\validate\store_product_unit\StoreProductUnitValidate;
/**
* 计量单位控制器
* Class StoreProductUnitController
* @package app\admin\controller\store_product_unit
*/
class StoreProductUnitController extends BaseAdminController
{
/**
* @notes 获取计量单位列表
* @return \think\response\Json
* @author admin
* @date 2024/05/31 15:50
*/
public function lists()
{
return $this->dataLists(new StoreProductUnitLists());
}
/**
* @notes 添加计量单位
* @return \think\response\Json
* @author admin
* @date 2024/05/31 15:50
*/
public function add()
{
$params = (new StoreProductUnitValidate())->post()->goCheck('add');
$result = StoreProductUnitLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(StoreProductUnitLogic::getError());
}
/**
* @notes 编辑计量单位
* @return \think\response\Json
* @author admin
* @date 2024/05/31 15:50
*/
public function edit()
{
$params = (new StoreProductUnitValidate())->post()->goCheck('edit');
$result = StoreProductUnitLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(StoreProductUnitLogic::getError());
}
/**
* @notes 删除计量单位
* @return \think\response\Json
* @author admin
* @date 2024/05/31 15:50
*/
public function delete()
{
$params = (new StoreProductUnitValidate())->post()->goCheck('delete');
StoreProductUnitLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取计量单位详情
* @return \think\response\Json
* @author admin
* @date 2024/05/31 15:50
*/
public function detail()
{
$params = (new StoreProductUnitValidate())->goCheck('detail');
$result = StoreProductUnitLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace app\admin\lists\store_order;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\store_order\StoreOrder;
use app\common\lists\ListsSearchInterface;
/**
* 订单列表列表
* Class StoreOrderLists
* @package app\admin\listsstore_order
*/
class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/05/31 16:02
*/
public function setSearch(): array
{
return [
'=' => ['order_id', 'pay_type'],
];
}
/**
* @notes 获取订单列表列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2024/05/31 16:02
*/
public function lists(): array
{
return StoreOrder::where($this->searchWhere)
->field(['id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取订单列表数量
* @return int
* @author admin
* @date 2024/05/31 16:02
*/
public function count(): int
{
return StoreOrder::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace app\admin\lists\store_product_unit;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\lists\ListsSearchInterface;
/**
* 计量单位列表
* Class StoreProductUnitLists
* @package app\admin\listsstore_product_unit
*/
class StoreProductUnitLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/05/31 15:50
*/
public function setSearch(): array
{
return [
'=' => ['name'],
];
}
/**
* @notes 获取计量单位列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2024/05/31 15:50
*/
public function lists(): array
{
return StoreProductUnit::where($this->searchWhere)
->field(['id', 'name', 'is_bulk', 'py', 'number', 'data'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取计量单位数量
* @return int
* @author admin
* @date 2024/05/31 15:50
*/
public function count(): int
{
return StoreProductUnit::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,94 @@
<?php
namespace app\admin\logic\store_order;
use app\common\model\store_order\StoreOrder;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 订单列表逻辑
* Class StoreOrderLogic
* @package app\admin\logic\store_order
*/
class StoreOrderLogic extends BaseLogic
{
/**
* @notes 添加订单列表
* @param array $params
* @return bool
* @author admin
* @date 2024/05/31 16:02
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
StoreOrder::create([
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑订单列表
* @param array $params
* @return bool
* @author admin
* @date 2024/05/31 16:02
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
StoreOrder::where('id', $params['id'])->update([
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除订单列表
* @param array $params
* @return bool
* @author admin
* @date 2024/05/31 16:02
*/
public static function delete(array $params): bool
{
return StoreOrder::destroy($params['id']);
}
/**
* @notes 获取订单列表详情
* @param $params
* @return array
* @author admin
* @date 2024/05/31 16:02
*/
public static function detail($params): array
{
return StoreOrder::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,104 @@
<?php
namespace app\admin\logic\store_product_unit;
use app\common\model\store_product_unit\StoreProductUnit;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 计量单位逻辑
* Class StoreProductUnitLogic
* @package app\admin\logic\store_product_unit
*/
class StoreProductUnitLogic extends BaseLogic
{
/**
* @notes 添加计量单位
* @param array $params
* @return bool
* @author admin
* @date 2024/05/31 15:50
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
StoreProductUnit::create([
'name' => $params['name'],
'is_bulk' => $params['is_bulk'],
'py' => $params['py'],
'number' => $params['number'],
'data' => $params['data'],
'more' => $params['more']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑计量单位
* @param array $params
* @return bool
* @author admin
* @date 2024/05/31 15:50
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
StoreProductUnit::where('id', $params['id'])->update([
'name' => $params['name'],
'is_bulk' => $params['is_bulk'],
'py' => $params['py'],
'number' => $params['number'],
'data' => $params['data'],
'more' => $params['more']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除计量单位
* @param array $params
* @return bool
* @author admin
* @date 2024/05/31 15:50
*/
public static function delete(array $params): bool
{
return StoreProductUnit::destroy($params['id']);
}
/**
* @notes 获取计量单位详情
* @param $params
* @return array
* @author admin
* @date 2024/05/31 15:50
*/
public static function detail($params): array
{
return StoreProductUnit::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace app\admin\validate\store_order;
use app\common\validate\BaseValidate;
/**
* 订单列表验证器
* Class StoreOrderValidate
* @package app\admin\validate\store_order
*/
class StoreOrderValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return StoreOrderValidate
* @author admin
* @date 2024/05/31 16:02
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return StoreOrderValidate
* @author admin
* @date 2024/05/31 16:02
*/
public function sceneEdit()
{
return $this->only(['id']);
}
/**
* @notes 删除场景
* @return StoreOrderValidate
* @author admin
* @date 2024/05/31 16:02
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return StoreOrderValidate
* @author admin
* @date 2024/05/31 16:02
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace app\admin\validate\store_product_unit;
use app\common\validate\BaseValidate;
/**
* 计量单位验证器
* Class StoreProductUnitValidate
* @package app\admin\validate\store_product_unit
*/
class StoreProductUnitValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'name' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'name' => '单位名称',
];
/**
* @notes 添加场景
* @return StoreProductUnitValidate
* @author admin
* @date 2024/05/31 15:50
*/
public function sceneAdd()
{
return $this->only(['name']);
}
/**
* @notes 编辑场景
* @return StoreProductUnitValidate
* @author admin
* @date 2024/05/31 15:50
*/
public function sceneEdit()
{
return $this->only(['id','name']);
}
/**
* @notes 删除场景
* @return StoreProductUnitValidate
* @author admin
* @date 2024/05/31 15:50
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return StoreProductUnitValidate
* @author admin
* @date 2024/05/31 15:50
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace app\common\model\store_order;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 订单列表模型
* Class StoreOrder
* @package app\common\model\store_order
*/
class StoreOrder extends BaseModel
{
use SoftDelete;
protected $name = 'store_order';
protected $deleteTime = 'delete_time';
}