Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
This commit is contained in:
commit
e5208db56d
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\system_store_storage;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\system_store_storage\SystemStoreStorageLists;
|
||||
use app\admin\logic\system_store_storage\SystemStoreStorageLogic;
|
||||
use app\admin\validate\system_store_storage\SystemStoreStorageValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 门店入库记录控制器
|
||||
* Class SystemStoreStorageController
|
||||
* @package app\admin\controller\system_store_storage
|
||||
*/
|
||||
class SystemStoreStorageController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店入库记录列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SystemStoreStorageLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加门店入库记录
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SystemStoreStorageValidate())->post()->goCheck('add');
|
||||
$result = SystemStoreStorageLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SystemStoreStorageLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑门店入库记录
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SystemStoreStorageValidate())->post()->goCheck('edit');
|
||||
$result = SystemStoreStorageLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SystemStoreStorageLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除门店入库记录
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SystemStoreStorageValidate())->post()->goCheck('delete');
|
||||
SystemStoreStorageLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店入库记录详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SystemStoreStorageValidate())->goCheck('detail');
|
||||
$result = SystemStoreStorageLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -37,7 +37,7 @@ class StoreRefundOrderLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$this->searchWhere['refund_status'] = ['>', 0];
|
||||
$this->searchWhere[] = ['refund_status','>', 0];
|
||||
return StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])
|
||||
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\system_store_storage;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 门店入库记录列表
|
||||
* Class SystemStoreStorageLists
|
||||
* @package app\admin\listssystem_store_storage
|
||||
*/
|
||||
class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'admin_id', 'operating_id', 'status'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店入库记录列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SystemStoreStorage::where($this->searchWhere)
|
||||
->field(['id', 'store_id', 'admin_id', 'operating_id', 'product_id', 'nums', 'status'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店入库记录数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SystemStoreStorage::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
104
app/admin/logic/system_store_storage/SystemStoreStorageLogic.php
Normal file
104
app/admin/logic/system_store_storage/SystemStoreStorageLogic.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\system_store_storage;
|
||||
|
||||
|
||||
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 门店入库记录逻辑
|
||||
* Class SystemStoreStorageLogic
|
||||
* @package app\admin\logic\system_store_storage
|
||||
*/
|
||||
class SystemStoreStorageLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加门店入库记录
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SystemStoreStorage::create([
|
||||
'store_id' => $params['store_id'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'operating_id' => $params['operating_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'nums' => $params['nums'],
|
||||
'status' => $params['status']
|
||||
]);
|
||||
|
||||
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/06/06 17:06
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SystemStoreStorage::where('id', $params['id'])->update([
|
||||
'store_id' => $params['store_id'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'operating_id' => $params['operating_id'],
|
||||
'product_id' => $params['product_id'],
|
||||
'nums' => $params['nums'],
|
||||
'status' => $params['status']
|
||||
]);
|
||||
|
||||
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/06/06 17:06
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SystemStoreStorage::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取门店入库记录详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return SystemStoreStorage::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\system_store_storage;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 门店入库记录验证器
|
||||
* Class SystemStoreStorageValidate
|
||||
* @package app\admin\validate\system_store_storage
|
||||
*/
|
||||
class SystemStoreStorageValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SystemStoreStorageValidate
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SystemStoreStorageValidate
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SystemStoreStorageValidate
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SystemStoreStorageValidate
|
||||
* @author admin
|
||||
* @date 2024/06/06 17:06
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user