Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
d2c269deb7
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\financial_transfers;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\financial_transfers\FinancialTransfersLists;
|
||||
use app\admin\logic\financial_transfers\FinancialTransfersLogic;
|
||||
use app\admin\validate\financial_transfers\FinancialTransfersValidate;
|
||||
|
||||
|
||||
/**
|
||||
* FinancialTransfers控制器
|
||||
* Class FinancialTransfersController
|
||||
* @package app\admin\controller\financial_transfers
|
||||
*/
|
||||
class FinancialTransfersController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialTransfersLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FinancialTransfersValidate())->post()->goCheck('add');
|
||||
$result = FinancialTransfersLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialTransfersLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FinancialTransfersValidate())->post()->goCheck('edit');
|
||||
$result = FinancialTransfersLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialTransfersLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FinancialTransfersValidate())->post()->goCheck('delete');
|
||||
FinancialTransfersLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FinancialTransfersValidate())->goCheck('detail');
|
||||
$result = FinancialTransfersLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\financial_transfers;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\financial_transfers\FinancialTransfers;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* FinancialTransfers列表
|
||||
* Class FinancialTransfersLists
|
||||
* @package app\admin\listsfinancial_transfers
|
||||
*/
|
||||
class FinancialTransfersLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'admin_id', 'uid', 'status', 'initiation_time', 'confirmation_time', 'mark', 'money', 'remark_time'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return FinancialTransfers::with(['store','staff','admin'])->where($this->searchWhere)
|
||||
// ->field(['id', 'store_id', 'admin_id', 'status', 'initiation_time', 'confirmation_time', 'mark', 'money', 'remark_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return FinancialTransfers::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
110
app/admin/logic/financial_transfers/FinancialTransfersLogic.php
Normal file
110
app/admin/logic/financial_transfers/FinancialTransfersLogic.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\financial_transfers;
|
||||
|
||||
|
||||
use app\common\model\financial_transfers\FinancialTransfers;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* FinancialTransfers逻辑
|
||||
* Class FinancialTransfersLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class FinancialTransfersLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:05
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialTransfers::create([
|
||||
'store_id' => $params['store_id'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'uid' => $params['uid'],
|
||||
'status' => $params['status'],
|
||||
'initiation_time' => $params['initiation_time'],
|
||||
'confirmation_time' => $params['confirmation_time'],
|
||||
'mark' => $params['mark'],
|
||||
'money' => $params['money'],
|
||||
'remark_time' => $params['remark_time']
|
||||
]);
|
||||
|
||||
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/14 10:05
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialTransfers::where('id', $params['id'])->update([
|
||||
'store_id' => $params['store_id'],
|
||||
'admin_id' => $params['admin_id'],
|
||||
'uid' => $params['uid'],
|
||||
'status' => $params['status'],
|
||||
'initiation_time' => $params['initiation_time'],
|
||||
'confirmation_time' => $params['confirmation_time'],
|
||||
'mark' => $params['mark'],
|
||||
'money' => $params['money'],
|
||||
'remark_time' => $params['remark_time']
|
||||
]);
|
||||
|
||||
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/14 10:05
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return FinancialTransfers::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:05
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return FinancialTransfers::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\financial_transfers;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* FinancialTransfers验证器
|
||||
* Class FinancialTransfersValidate
|
||||
* @package app\admin\validate\financial_transfers
|
||||
*/
|
||||
class FinancialTransfersValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'store_id' => 'require',
|
||||
'money' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'store_id' => '店铺id',
|
||||
'money' => '金额',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FinancialTransfersValidate
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['store_id','money']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FinancialTransfersValidate
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','store_id','money']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FinancialTransfersValidate
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FinancialTransfersValidate
|
||||
* @author admin
|
||||
* @date 2024/06/14 10:10
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
45
app/common/model/financial_transfers/FinancialTransfers.php
Normal file
45
app/common/model/financial_transfers/FinancialTransfers.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\financial_transfers;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 财务转账提现表模型
|
||||
* Class FinancaialTransfers
|
||||
* @package app\common\model\order
|
||||
*/
|
||||
class FinancialTransfers extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'financial_transfers';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
return $this->hasOne(SystemStore::class, 'id','store_id')
|
||||
->bind(['store_name'=>'name', 'store_phone'=>'phone','store_detailed_address'=>'detailed_address','store_simple_address'=>'address']);
|
||||
}
|
||||
|
||||
|
||||
public function staff()
|
||||
{
|
||||
return $this->hasOne(SystemStoreStaff::class, 'id', 'store_staff_id')->bind(['staff_name']);
|
||||
}
|
||||
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->hasOne(Admin::class, 'id','admin_id')
|
||||
->bind(['admin_name'=>'name']);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user