From b7b6edb06c35a1194255ba11c19a8303503d77d9 Mon Sep 17 00:00:00 2001 From: mzl Date: Thu, 18 Sep 2025 15:05:57 +0800 Subject: [PATCH] Merge branch 'develop' --- .gitignore | 3 +- .../controller/ApprovalFlowsController.php | 2 +- .../ApprovalInstancesController.php | 2 +- .../controller/ApprovalRecordsController.php | 72 +- app/admin/logic/ApprovalInstancesLogic.php | 17 - app/admin/logic/ApprovalRecordsLogic.php | 17 - app/admin/model/ApprovalFlows.php | 54 -- app/admin/model/ApprovalInstances.php | 107 --- app/admin/model/ApprovalRecords.php | 84 --- .../logic/ApprovalFlowsLogic.php | 4 +- .../logic/ApprovalInstancesLogic.php | 4 +- .../logic/ApprovalRecordsLogic.php | 4 +- .../approval => }/model/ApprovalCcs.php | 4 +- app/{crm => common}/model/ApprovalFlows.php | 5 +- .../model/ApprovalInstances.php | 36 +- app/{crm => common}/model/ApprovalRecords.php | 20 +- .../service/ApprovalFlowsService.php | 6 +- .../service/ApprovalInstancesService.php | 6 +- .../service/ApprovalRecordsService.php | 41 +- .../service/MessageNotificationsService.php | 2 +- .../service/MessageUserStatusService.php | 2 +- app/common/service/ResourceService.php | 2 +- app/common/service/StockOrdersService.php | 4 +- app/common/service/SysDictService.php | 10 +- app/common/traits/crud/CrudServiceTrait.php | 69 +- .../traits/crud/CrudServiceTrait_bak.php | 194 ++++++ .../utils/approval/model/ApprovalFlows.php | 49 -- .../approval/model/ApprovalInstances.php | 49 -- .../utils/approval/model/ApprovalRecords.php | 49 -- .../approval/service/ApprovalFlowService.php | 28 +- .../validate/ApprovalFlowsValidate.php | 2 +- .../validate/ApprovalInstancesValidate.php | 2 +- .../validate/ApprovalRecordsValidate.php | 2 +- app/controller/IndexController.php | 53 +- .../controller/ApprovalFlowsController.php | 2 +- .../ApprovalInstancesController.php | 2 +- .../controller/ApprovalRecordsController.php | 56 +- app/crm/logic/ApprovalFlowsLogic.php | 17 - app/crm/service/ApprovalFlowsService.php | 31 - app/crm/service/ApprovalInstancesService.php | 31 - app/crm/service/ApprovalRecordsService.php | 91 --- app/crm/service/StockOrdersService.php | 4 +- composer.json | 1 - composer.lock | 648 +----------------- config/route.php | 4 + webman | 142 ++-- 46 files changed, 522 insertions(+), 1512 deletions(-) delete mode 100644 app/admin/logic/ApprovalInstancesLogic.php delete mode 100644 app/admin/logic/ApprovalRecordsLogic.php delete mode 100644 app/admin/model/ApprovalFlows.php delete mode 100644 app/admin/model/ApprovalInstances.php delete mode 100644 app/admin/model/ApprovalRecords.php rename app/{admin => common}/logic/ApprovalFlowsLogic.php (77%) rename app/{crm => common}/logic/ApprovalInstancesLogic.php (76%) rename app/{crm => common}/logic/ApprovalRecordsLogic.php (77%) rename app/common/{utils/approval => }/model/ApprovalCcs.php (91%) rename app/{crm => common}/model/ApprovalFlows.php (93%) rename app/{crm => common}/model/ApprovalInstances.php (87%) rename app/{crm => common}/model/ApprovalRecords.php (74%) rename app/{admin => common}/service/ApprovalFlowsService.php (91%) rename app/{admin => common}/service/ApprovalInstancesService.php (78%) rename app/{admin => common}/service/ApprovalRecordsService.php (62%) create mode 100644 app/common/traits/crud/CrudServiceTrait_bak.php delete mode 100644 app/common/utils/approval/model/ApprovalFlows.php delete mode 100644 app/common/utils/approval/model/ApprovalInstances.php delete mode 100644 app/common/utils/approval/model/ApprovalRecords.php rename app/{admin => common}/validate/ApprovalFlowsValidate.php (91%) rename app/{admin => common}/validate/ApprovalInstancesValidate.php (91%) rename app/{admin => common}/validate/ApprovalRecordsValidate.php (91%) delete mode 100644 app/crm/logic/ApprovalFlowsLogic.php delete mode 100644 app/crm/service/ApprovalFlowsService.php delete mode 100644 app/crm/service/ApprovalInstancesService.php delete mode 100644 app/crm/service/ApprovalRecordsService.php mode change 100755 => 100644 webman diff --git a/.gitignore b/.gitignore index 496f0a0..fa572a1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ .env /tests/tmp /tests/.phpunit.result.cache -/public/uploads \ No newline at end of file +/public/uploads +/webman \ No newline at end of file diff --git a/app/admin/controller/ApprovalFlowsController.php b/app/admin/controller/ApprovalFlowsController.php index c2babff..ec9bb60 100644 --- a/app/admin/controller/ApprovalFlowsController.php +++ b/app/admin/controller/ApprovalFlowsController.php @@ -3,7 +3,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; use app\common\traits\crud\CrudControllerTrait; -use app\admin\service\ApprovalFlowsService; +use app\common\service\ApprovalFlowsService; class ApprovalFlowsController extends BaseController { diff --git a/app/admin/controller/ApprovalInstancesController.php b/app/admin/controller/ApprovalInstancesController.php index 483ec40..c7bf7fb 100644 --- a/app/admin/controller/ApprovalInstancesController.php +++ b/app/admin/controller/ApprovalInstancesController.php @@ -3,7 +3,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; use app\common\traits\crud\CrudControllerTrait; -use app\admin\service\ApprovalInstancesService; +use app\common\service\ApprovalInstancesService; class ApprovalInstancesController extends BaseController { diff --git a/app/admin/controller/ApprovalRecordsController.php b/app/admin/controller/ApprovalRecordsController.php index 1bf914e..2506845 100644 --- a/app/admin/controller/ApprovalRecordsController.php +++ b/app/admin/controller/ApprovalRecordsController.php @@ -3,8 +3,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; use app\common\traits\crud\CrudControllerTrait; -use app\admin\service\ApprovalRecordsService; -use app\admin\service\SysDictService; +use app\common\service\ApprovalRecordsService; use app\common\model\SysDictItem; use support\Request; @@ -31,16 +30,16 @@ class ApprovalRecordsController extends BaseController foreach ($data['records'] as $key => &$record) { $result = [ 'id' => $record['id'], - 'flows_name' => $record['approvalInstance']['flows']['name'], + 'flows_name' => $record['instance']['flows']['name'], 'instance_id' => $record['instance_id'], - 'biz_id' => $record['approvalInstance']['biz_id'], - 'biz_desc' => '备货单【'.$record['approvalInstance']['bizInfo']['order_no'].'】', - 'biz_type' => $record['approvalInstance']['flow_type'], + 'biz_id' => $record['instance']['biz_id'], + 'biz_desc' => '备货单【'.$record['instance']['bizInfo']['order_no'].'】', + 'biz_type' => $record['instance']['flow_type'], - 'initiator_name' => $record['approvalInstance']['initiator']['name'], - 'initiator_avatar' => $record['approvalInstance']['initiator']['avatar'], + 'initiator_name' => $record['instance']['initiator']['name'], + 'initiator_avatar' => $record['instance']['initiator']['avatar'], 'approver_name' => $record['approver']['name'], 'approver_avatar' => $record['approver']['avatar'], @@ -53,8 +52,8 @@ class ApprovalRecordsController extends BaseController 'comment' => $record['comment'], 'approved_at' => $record['approved_at'], - 'finished_at' => $record['approvalInstance']['finished_at'], - 'deadline_at' => $record['approvalInstance']['deadline_at'], + 'finished_at' => $record['instance']['finished_at'], + 'deadline_at' => $record['instance']['deadline_at'], 'created_at' => $record['created_at'] ]; @@ -87,4 +86,57 @@ class ApprovalRecordsController extends BaseController return $this->error($e->getMessage()); } } + + + public function todo(Request $request) + { + try { + $raw = $this->service->serviceList($request, 'todo'); + $data = $this->transformData($raw, method_exists($this, 'todoFormat') + ? [$this, 'todoFormat'] + : null); + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + protected function todoFormat($data) + { + if (isset($data['records']) && count($data['records']) > 0) { + foreach ($data['records'] as $key => &$record) { + $result = [ + 'id' => $record['id'], + 'flows_name' => $record['instance']['flows']['name'], + + 'instance_id' => $record['instance_id'], + + 'biz_id' => $record['instance']['biz_id'], + 'biz_desc' => '备货单号【'.$record['instance']['bizInfo']['order_no'].'】', + 'biz_type' => $record['instance']['flow_type'], + + 'initiator_name' => $record['instance']['initiator']['name'], + 'initiator_avatar' => $record['instance']['initiator']['avatar'], + + 'approver_name' => $record['approver']['name'], + 'approver_avatar' => $record['approver']['avatar'], + + 'step_index' => $record['step_index'], + 'action' => $record['action'], + 'action_desc' => SysDictItem::where('item_value', $record['action'])->where('status', 1)->value('item_label'), + 'status' => $record['status'], + 'status_desc' => SysDictItem::where('item_value', $record['status'])->where('status', 1)->value('item_label'), + 'comment' => $record['comment'], + 'approved_at' => $record['approved_at'], + + 'finished_at' => $record['instance']['finished_at'], + 'deadline_at' => $record['instance']['deadline_at'], + + 'created_at' => $record['created_at'] + ]; + $record = $result; + } + } + return $data; + } } \ No newline at end of file diff --git a/app/admin/logic/ApprovalInstancesLogic.php b/app/admin/logic/ApprovalInstancesLogic.php deleted file mode 100644 index bc8ce88..0000000 --- a/app/admin/logic/ApprovalInstancesLogic.php +++ /dev/null @@ -1,17 +0,0 @@ - 'array', - ]; -} \ No newline at end of file diff --git a/app/admin/model/ApprovalInstances.php b/app/admin/model/ApprovalInstances.php deleted file mode 100644 index b09ff5d..0000000 --- a/app/admin/model/ApprovalInstances.php +++ /dev/null @@ -1,107 +0,0 @@ - 'array', // 自动转换 JSON 字段为数组 - 'finished_at' => 'datetime', - 'deadline_at' => 'datetime', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - ]; - - /** - * 一个审批实例可以有多个审批记录 - */ - public function approvalRecords(): HasMany - { - return $this->hasMany(ApprovalRecords::class, 'instance_id'); - } - - /** - * 获取当前步骤的所有审批记录(pending 状态) - */ - public function currentStepRecords() - { - return $this->approvalRecords() - ->where('step_index', $this->current_step) - ->where('status', 'pending'); - } - - public function flows() - { - return $this->belongsTo(ApprovalFlows::class, 'flow_type', 'type'); - } - - public function initiator() - { - return $this->belongsTo(User::class, 'initiator_id', 'id'); - } - - - public function bizInfo() - { - return $this->hasOne(StockOrders::class, 'id', 'biz_id'); - } -} \ No newline at end of file diff --git a/app/admin/model/ApprovalRecords.php b/app/admin/model/ApprovalRecords.php deleted file mode 100644 index a970ce4..0000000 --- a/app/admin/model/ApprovalRecords.php +++ /dev/null @@ -1,84 +0,0 @@ - 'datetime', - 'created_at' => 'datetime', - 'updated_at' => 'datetime', - ]; - - /** - * 一条审批记录属于一个审批实例 - */ - public function approvalInstance(): BelongsTo - { - return $this->belongsTo(ApprovalInstances::class, 'instance_id'); - } - - /** - * 关联审批人 - */ - public function approver() - { - return $this->belongsTo(User::class, 'approver_id'); - } -} \ No newline at end of file diff --git a/app/admin/logic/ApprovalFlowsLogic.php b/app/common/logic/ApprovalFlowsLogic.php similarity index 77% rename from app/admin/logic/ApprovalFlowsLogic.php rename to app/common/logic/ApprovalFlowsLogic.php index 1608782..2157d28 100644 --- a/app/admin/logic/ApprovalFlowsLogic.php +++ b/app/common/logic/ApprovalFlowsLogic.php @@ -1,9 +1,9 @@ 'array', ]; diff --git a/app/crm/model/ApprovalInstances.php b/app/common/model/ApprovalInstances.php similarity index 87% rename from app/crm/model/ApprovalInstances.php rename to app/common/model/ApprovalInstances.php index b5a9a7b..48fe707 100644 --- a/app/crm/model/ApprovalInstances.php +++ b/app/common/model/ApprovalInstances.php @@ -1,11 +1,10 @@ 'datetime', ]; - /** - * 一个审批实例可以有多个审批记录 - */ - public function approvalRecords(): HasMany + public function records() { - return $this->hasMany(ApprovalRecords::class, 'instance_id'); - } - - /** - * 获取当前步骤的所有审批记录(pending 状态) - */ - public function currentStepRecords() - { - return $this->approvalRecords() - ->where('step_index', $this->current_step) - ->where('status', 'pending'); + return $this->hasMany(ApprovalRecords::class, 'instance_id', 'id'); } public function flows() @@ -99,9 +84,18 @@ class ApprovalInstances extends Model return $this->belongsTo(User::class, 'initiator_id', 'id'); } - public function bizInfo() { - return $this->hasOne(StockOrders::class, 'id', 'biz_id'); + return $this->belongsTo(StockOrders::class, 'biz_id', 'id'); + } + + /** + * 获取当前步骤的所有审批记录(pending 状态) + */ + public function currentStepRecords() + { + return $this->approvalRecords() + ->where('step_index', $this->current_step) + ->where('status', 'pending'); } } \ No newline at end of file diff --git a/app/crm/model/ApprovalRecords.php b/app/common/model/ApprovalRecords.php similarity index 74% rename from app/crm/model/ApprovalRecords.php rename to app/common/model/ApprovalRecords.php index 4f4ea06..660f1a4 100644 --- a/app/crm/model/ApprovalRecords.php +++ b/app/common/model/ApprovalRecords.php @@ -1,10 +1,9 @@ 'datetime', ]; - /** - * 一条审批记录属于一个审批实例 - */ - public function approvalInstance(): BelongsTo + public function instance() { - return $this->belongsTo(ApprovalInstances::class, 'instance_id'); + return $this->belongsTo(ApprovalInstances::class, 'instance_id', 'id'); } - /** - * 关联审批人 - */ + public function approver() { - return $this->belongsTo(User::class, 'approver_id'); + return $this->belongsTo(User::class, 'approver_id', 'id'); } } \ No newline at end of file diff --git a/app/admin/service/ApprovalFlowsService.php b/app/common/service/ApprovalFlowsService.php similarity index 91% rename from app/admin/service/ApprovalFlowsService.php rename to app/common/service/ApprovalFlowsService.php index 3f7a4e9..726f5cf 100644 --- a/app/admin/service/ApprovalFlowsService.php +++ b/app/common/service/ApprovalFlowsService.php @@ -1,10 +1,10 @@ user->uid; // $config['dataLimit']['userField'] = 'approver_id'; break; + case 'todo': + + if ($p['scene'] === 'todo') { + // if (!in_array(1, $request->user->role_ids)) { + $config['where']['approver_id'] = $request->user->uid; + // } + $config['where']['status'] = 'pending'; + $config['where']['instance.status'] = 'processing'; + } + + if ($p['scene'] === 'history') { + if (!in_array(1, $request->user->role_ids)) { + $config['where']['approver_id'] = $request->user->uid; + } + $config['where']['status'] = ['!=', 'pending']; + } + + $config['order']['id'] = 'desc'; + + $config['with'] = [ + 'instance', + 'approver', + 'instance.flows', + 'instance.initiator', + 'instance.bizInfo' + ]; + break; case 'show': $config['where']['id'] = $p['id']; break; diff --git a/app/common/service/MessageNotificationsService.php b/app/common/service/MessageNotificationsService.php index a225a73..cebd4b9 100644 --- a/app/common/service/MessageNotificationsService.php +++ b/app/common/service/MessageNotificationsService.php @@ -86,7 +86,7 @@ class MessageNotificationsService return ['msg_id' => $msgId]; } - public function afterServiceList($data) + public function afterServiceIndex($data) { $data->each(function (&$item) { $temp = explode(',', $item->recipient); diff --git a/app/common/service/MessageUserStatusService.php b/app/common/service/MessageUserStatusService.php index 2162f86..ca324dc 100644 --- a/app/common/service/MessageUserStatusService.php +++ b/app/common/service/MessageUserStatusService.php @@ -97,7 +97,7 @@ class MessageUserStatusService } - protected function afterServiceList($res) + protected function afterServiceIndex($res) { $res->each(function (&$item) { if (isset($item->message)) { diff --git a/app/common/service/ResourceService.php b/app/common/service/ResourceService.php index c1654a5..2d093f8 100644 --- a/app/common/service/ResourceService.php +++ b/app/common/service/ResourceService.php @@ -95,7 +95,7 @@ class ResourceService } - protected function afterServiceListAll($data) + protected function afterServiceDefault($data) { $data = Tree::buildMenuTreeWithReference($data->toArray()); return $data; diff --git a/app/common/service/StockOrdersService.php b/app/common/service/StockOrdersService.php index e87d37b..9308fde 100644 --- a/app/common/service/StockOrdersService.php +++ b/app/common/service/StockOrdersService.php @@ -13,8 +13,8 @@ use support\Request; use app\common\model\User; use support\Db; use support\Model; -use app\admin\model\ApprovalInstances; -use app\admin\model\ApprovalRecords; +use app\common\model\ApprovalInstances; +use app\common\model\ApprovalRecords; class StockOrdersService { diff --git a/app/common/service/SysDictService.php b/app/common/service/SysDictService.php index 4f22070..4918017 100644 --- a/app/common/service/SysDictService.php +++ b/app/common/service/SysDictService.php @@ -28,23 +28,25 @@ class SysDictService - public static function pluckValuesByCode(string $dictCode): \Illuminate\Support\Collection + public static function pluckValuesByCode(string $dictCode): array { return SysDict::where('dict_code', $dictCode) ->where('status', 1) ->first()?->items() ->where('status', 1) ->orderBy('sort') - ->pluck('item_value') ?? collect(); + ->pluck('item_value') + ->toArray() ?? []; } - public static function pluckKeyValueByCode(string $dictCode): \Illuminate\Support\Collection + public static function pluckKeyValueByCode(string $dictCode): array { return SysDict::where('dict_code', $dictCode) ->where('status', 1) ->first()?->items() ->where('status', 1) ->orderBy('sort') - ->pluck('item_value', 'item_label') ?? collect(); + ->pluck('item_value', 'item_label') + ->toArray() ?? []; } } \ No newline at end of file diff --git a/app/common/traits/crud/CrudServiceTrait.php b/app/common/traits/crud/CrudServiceTrait.php index dd4536f..eb563fe 100644 --- a/app/common/traits/crud/CrudServiceTrait.php +++ b/app/common/traits/crud/CrudServiceTrait.php @@ -27,63 +27,61 @@ trait CrudServiceTrait } /** 分页列表 */ - public function serviceList(Request $request) + public function serviceList(Request $request, string $scene = 'index') { - if (method_exists($this, 'complexQuery')) { - $result = $this->complexQuery($request->get()); - } else { - $config = $this->buildQueryConfig($request, 'index'); + $result = $this->cqyProcess(ucfirst($scene), $request); + if ($result === false) { + $config = $this->buildQueryConfig($request, $scene); $limit = (int)$request->get('size', 15); $page = (int)$request->get('current', 1); $result = $this->logicList($config, $limit, $page); } - return $this->postProcess('List', $result); + return $this->postProcess(ucfirst($scene), $result); } /** 全量列表 */ - public function serviceListAll(Request $request) + public function serviceListAll(Request $request, string $scene = 'default') { - if (method_exists($this, 'complexQuery')) { - $result = $this->complexQuery($request->get()); - } else { - $config = $this->buildQueryConfig($request, 'default'); + $result = $this->cqyProcess(ucfirst($scene), $request); + if ($result === false) { + $config = $this->buildQueryConfig($request, $scene); $result = $this->logicListAll($config); } - return $this->postProcess('ListAll', $result); + return $this->postProcess(ucfirst($scene), $result); } /** 查看单条 */ - public function serviceShow(Request $request) + public function serviceShow(Request $request, string $scene = 'show') { - $config = $this->buildQueryConfig($request, 'show'); + $config = $this->buildQueryConfig($request, $scene); $item = $this->logicShow($config); - return $this->postProcess('Show', $item); + return $this->postProcess(ucfirst($scene), $item); } /** 创建 */ - public function serviceStore(Request $request, array $data = []) + public function serviceStore(Request $request, array $data = [], string $scene = 'store') { - $data = $this->preProcess('Store', $data, $request); + $data = $this->preProcess(ucfirst($scene), $data, $request); $dl = $this->getDataLimitFromRequest($request); $created = $this->logicCreate($data, $dl); - return $this->postProcess('Store', $created); + return $this->postProcess(ucfirst($scene), $created); } /** 更新 */ - public function serviceUpdate(Request $request, array $data = []) + public function serviceUpdate(Request $request, array $data = [], string $scene = 'update') { - $data = $this->preProcess('Update', $data, $request); - $config = $this->buildQueryConfig($request, 'update'); + $data = $this->preProcess(ucfirst($scene), $data, $request); + $config = $this->buildQueryConfig($request, $scene); $updated = $this->logicUpdateBy($config, $data); - return $this->postProcess('Update', $data); + return $this->postProcess(ucfirst($scene), $data); } /** 删除 */ - public function serviceDestroy(Request $request) + public function serviceDestroy(Request $request, string $scene = 'destroy') { - $config = $this->buildQueryConfig($request, 'destroy'); + $config = $this->buildQueryConfig($request, $scene); $deleted = $this->logicDeleteBy($config); - return $this->postProcess('Destroy', $deleted); + return $this->postProcess(ucfirst($scene), $deleted); } /** ----------------- 公共辅助方法 ----------------- */ @@ -182,13 +180,18 @@ trait CrudServiceTrait : $data; } - - /** - * 处理复杂查询 - * 覆盖此方法,实现复杂查询逻辑 + /** + * 复杂/自定义查询 + * + * @param string $op 场景 + * @param mixed $data 原始返回值 + * @return mixed 处理后的返回值 */ - // protected function complexQuery(array $params): array - // { - // throw new BusinessException('请在子类实现 complexQuery'); - // } + protected function cqyProcess(string $op, Request $request): mixed + { + $hook = "complexQuery{$op}"; + return method_exists($this, $hook) + ? $this->{$hook}($request) + : false; + } } \ No newline at end of file diff --git a/app/common/traits/crud/CrudServiceTrait_bak.php b/app/common/traits/crud/CrudServiceTrait_bak.php new file mode 100644 index 0000000..4b2e012 --- /dev/null +++ b/app/common/traits/crud/CrudServiceTrait_bak.php @@ -0,0 +1,194 @@ +validator; + } + + /** 分页列表 */ + public function serviceList(Request $request) + { + if (method_exists($this, 'complexQuery')) { + $result = $this->complexQuery($request->get()); + } else { + $config = $this->buildQueryConfig($request, 'index'); + $limit = (int)$request->get('size', 15); + $page = (int)$request->get('current', 1); + $result = $this->logicList($config, $limit, $page); + } + return $this->postProcess('List', $result); + } + + /** 全量列表 */ + public function serviceListAll(Request $request) + { + if (method_exists($this, 'complexQuery')) { + $result = $this->complexQuery($request->get()); + } else { + $config = $this->buildQueryConfig($request, 'default'); + $result = $this->logicListAll($config); + } + return $this->postProcess('ListAll', $result); + } + + /** 查看单条 */ + public function serviceShow(Request $request) + { + $config = $this->buildQueryConfig($request, 'show'); + $item = $this->logicShow($config); + return $this->postProcess('Show', $item); + } + + /** 创建 */ + public function serviceStore(Request $request, array $data = []) + { + $data = $this->preProcess('Store', $data, $request); + $dl = $this->getDataLimitFromRequest($request); + $created = $this->logicCreate($data, $dl); + return $this->postProcess('Store', $created); + } + + /** 更新 */ + public function serviceUpdate(Request $request, array $data = []) + { + $data = $this->preProcess('Update', $data, $request); + $config = $this->buildQueryConfig($request, 'update'); + $updated = $this->logicUpdateBy($config, $data); + return $this->postProcess('Update', $data); + } + + /** 删除 */ + public function serviceDestroy(Request $request) + { + $config = $this->buildQueryConfig($request, 'destroy'); + $deleted = $this->logicDeleteBy($config); + return $this->postProcess('Destroy', $deleted); + } + + /** ----------------- 公共辅助方法 ----------------- */ + + /** + * 构造 CrudUtil 查询配置 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'default': + $config['where']['status'] = 1; + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + break; + case 'index': + $config['where']['status'] = 1; + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + break; + case 'show': + $config['where']['id'] = $p['id']; + $config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } + + /** 解析 withFields 字符串 "rel:field,field;..." */ + protected function parseWithFields(string $str): array + { + if (!$str) { + return []; + } + $out = []; + foreach (explode(';', $str) as $pair) { + [$rel, $flds] = explode(':', $pair); + $out[$rel] = explode(',', $flds); + } + return $out; + } + + /** 从请求读取 dataLimitType, dataLimitField */ + protected function getDataLimitFromRequest(Request $req): array + { + $type = $req->get('dataLimitType'); + if (!$type) { + return []; + } + return [ + 'type' => $type, + 'field' => $req->get('dataLimitField', 'admin_id'), + ]; + } + + /** + * $data 前置处理 + * + * @param array $data + * @param Request $request + * @return array + */ + protected function preProcess(string $op, mixed $data, Request $request): mixed + { + $hook = "beforeService{$op}"; + return method_exists($this, $hook) + ? $this->{$hook}($data, $request) + : $data; + } + + /** + * 根据操作类型,调用对应的后置钩子 + * + * @param string $op 操作:List, Show, Store, Update, Destroy + * @param mixed $data 原始返回值 + * @return mixed 处理后的返回值 + */ + protected function postProcess(string $op, mixed $data): mixed + { + $hook = "afterService{$op}"; + return method_exists($this, $hook) + ? $this->{$hook}($data) + : $data; + } + + + /** + * 处理复杂查询 + * 覆盖此方法,实现复杂查询逻辑 + */ + // protected function complexQuery(array $params): array + // { + // throw new BusinessException('请在子类实现 complexQuery'); + // } +} \ No newline at end of file diff --git a/app/common/utils/approval/model/ApprovalFlows.php b/app/common/utils/approval/model/ApprovalFlows.php deleted file mode 100644 index 7c6fea1..0000000 --- a/app/common/utils/approval/model/ApprovalFlows.php +++ /dev/null @@ -1,49 +0,0 @@ -join('approval_instances as ai', 'ar.instance_id', '=', 'ai.id') - ->where('ar.approver_id', $userId) - ->where('ar.status', 'pending') - ->where('ai.status', 'processing') - ->select('ai.*') - ->distinct() - ->get() - ->toArray(); - } - - /** 审批历史 */ - public function getApprovalHistory(int $instanceId): array - { - return Db::table('approval_records') - ->where('instance_id', $instanceId) - ->orderBy('step_index') - ->orderByRaw('COALESCE(approved_at, created_at) asc') - ->get() - ->toArray(); - } - /** 流程图数据(把 skipped/timeout 视作已完结的中性状态) */ public function getFlowDiagramData(int $instanceId): array { @@ -577,7 +551,7 @@ class ApprovalFlowService $prefix = $isCC ? '【抄送】' : '【审批】'; $text = $map[$action] ?? $action; - $approvalType = array_flip(\app\common\service\SysDictService::pluckKeyValueByCode('approval_type')->toArray()); + $approvalType = array_flip(\app\common\service\SysDictService::pluckKeyValueByCode('approval_type')); switch ($instance->flow_type) { case 'stock_orders': // 备货单 diff --git a/app/admin/validate/ApprovalFlowsValidate.php b/app/common/validate/ApprovalFlowsValidate.php similarity index 91% rename from app/admin/validate/ApprovalFlowsValidate.php rename to app/common/validate/ApprovalFlowsValidate.php index 9b64000..4e4cb4d 100644 --- a/app/admin/validate/ApprovalFlowsValidate.php +++ b/app/common/validate/ApprovalFlowsValidate.php @@ -1,6 +1,6 @@ ', 141]; - $list = (new \app\common\utils\MigrationResources())->getFullResourceTreeOptimized('resources', $where); - - - $keys = ['system_id','name','desc','type','code','parent_id','url','icon','open_type','link', - 'is_hide','is_hide_tab','no_auth','is_home','instance','keep_alive','sort','status']; - foreach ($list as $key=>$item) { - - - $temp = []; - - foreach ($item as $k=>$v) { - - if (isset($item['children']) && count($item['children']) > 0) { - $temp = $item['children']; - } - - if (!in_array($k, $keys)) { - unset($item[$k]); - } - - $id = Db::table('resources')->insertGetId($item); - - if ($temp) { - foreach ($temp as $kc=>$vc) { - - foreach ($vc as $kk => $vv) { - if (!in_array($kk, $keys)) { - unset($vc[$kk]); - } - } - - $vc['parent_id'] = $id; - - Db::table('resources')->insert($vc); - } - - } - - } - } - } - - - public function test(Request $request) { // 菜单迁移 - $where[] = ['id', '>', 141]; - $list = (new \app\common\utils\MigrationResources())->do('resources_20250916_bak', 'resources_yuanshi', $where); + // $where[] = ['id', '>', 141]; + // $list = (new \app\common\utils\MigrationResources())->do('resources_20250916_bak', 'resources_yuanshi', $where); + $list = (new \app\common\utils\MigrationResources())->getFullResourceTreeOptimized('resources_20250916_bak', []); + var_dump($list); } } \ No newline at end of file diff --git a/app/crm/controller/ApprovalFlowsController.php b/app/crm/controller/ApprovalFlowsController.php index 7eacb12..c97fa87 100644 --- a/app/crm/controller/ApprovalFlowsController.php +++ b/app/crm/controller/ApprovalFlowsController.php @@ -3,7 +3,7 @@ namespace app\crm\controller; use app\common\controller\BaseController; use app\common\traits\crud\CrudControllerTrait; -use app\crm\service\ApprovalFlowsService; +use app\common\service\ApprovalFlowsService; class ApprovalFlowsController extends BaseController { diff --git a/app/crm/controller/ApprovalInstancesController.php b/app/crm/controller/ApprovalInstancesController.php index e854af6..3643489 100644 --- a/app/crm/controller/ApprovalInstancesController.php +++ b/app/crm/controller/ApprovalInstancesController.php @@ -3,7 +3,7 @@ namespace app\crm\controller; use app\common\controller\BaseController; use app\common\traits\crud\CrudControllerTrait; -use app\crm\service\ApprovalInstancesService; +use app\common\service\ApprovalInstancesService; class ApprovalInstancesController extends BaseController { diff --git a/app/crm/controller/ApprovalRecordsController.php b/app/crm/controller/ApprovalRecordsController.php index 3edc6b5..ca68d9f 100644 --- a/app/crm/controller/ApprovalRecordsController.php +++ b/app/crm/controller/ApprovalRecordsController.php @@ -3,7 +3,7 @@ namespace app\crm\controller; use app\common\controller\BaseController; use app\common\traits\crud\CrudControllerTrait; -use app\crm\service\ApprovalRecordsService; +use app\common\service\ApprovalRecordsService; use app\common\model\SysDictItem; use support\Request; @@ -86,4 +86,58 @@ class ApprovalRecordsController extends BaseController return $this->error($e->getMessage()); } } + + + + public function todo(Request $request) + { + try { + $raw = $this->service->serviceList($request, 'todo'); + $data = $this->transformData($raw, method_exists($this, 'todoFormat') + ? [$this, 'todoFormat'] + : null); + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + protected function todoFormat($data) + { + if (isset($data['records']) && count($data['records']) > 0) { + foreach ($data['records'] as $key => &$record) { + $result = [ + 'id' => $record['id'], + 'flows_name' => $record['approvalInstance']['flows']['name'], + + 'instance_id' => $record['instance_id'], + + 'biz_id' => $record['approvalInstance']['biz_id'], + 'biz_desc' => '备货单号【'.$record['approvalInstance']['bizInfo']['order_no'].'】', + 'biz_type' => $record['approvalInstance']['flow_type'], + + 'initiator_name' => $record['approvalInstance']['initiator']['name'], + 'initiator_avatar' => $record['approvalInstance']['initiator']['avatar'], + + 'approver_name' => $record['approver']['name'], + 'approver_avatar' => $record['approver']['avatar'], + + 'step_index' => $record['step_index'], + 'action' => $record['action'], + 'action_desc' => SysDictItem::where('item_value', $record['action'])->where('status', 1)->value('item_label'), + 'status' => $record['status'], + 'status_desc' => SysDictItem::where('item_value', $record['status'])->where('status', 1)->value('item_label'), + 'comment' => $record['comment'], + 'approved_at' => $record['approved_at'], + + 'finished_at' => $record['approvalInstance']['finished_at'], + 'deadline_at' => $record['approvalInstance']['deadline_at'], + + 'created_at' => $record['created_at'] + ]; + $record = $result; + } + } + return $data; + } } \ No newline at end of file diff --git a/app/crm/logic/ApprovalFlowsLogic.php b/app/crm/logic/ApprovalFlowsLogic.php deleted file mode 100644 index 8a5260f..0000000 --- a/app/crm/logic/ApprovalFlowsLogic.php +++ /dev/null @@ -1,17 +0,0 @@ -validator; - } -} \ No newline at end of file diff --git a/app/crm/service/ApprovalInstancesService.php b/app/crm/service/ApprovalInstancesService.php deleted file mode 100644 index 86e6e57..0000000 --- a/app/crm/service/ApprovalInstancesService.php +++ /dev/null @@ -1,31 +0,0 @@ -validator; - } -} \ No newline at end of file diff --git a/app/crm/service/ApprovalRecordsService.php b/app/crm/service/ApprovalRecordsService.php deleted file mode 100644 index 16c070d..0000000 --- a/app/crm/service/ApprovalRecordsService.php +++ /dev/null @@ -1,91 +0,0 @@ -validator; - } - - - protected function buildQueryConfig(Request $request, string $scene = 'default'): array - { - $p = $request->all(); - - $config = []; - $config['model'] = $this->modelClass; - switch ($scene) { - case 'index': - $config['order']['id'] = 'desc'; - - $config['with'] = [ - 'approvalInstance', - 'approver', - 'approvalInstance.flows', - 'approvalInstance.initiator', - 'approvalInstance.bizInfo' - ]; - - $config['dataLimit']['type'] = 'relation'; - $config['dataLimit']['userId'] = $request->user->uid; - $config['dataLimit']['userField'] = 'approver_id'; - break; - case 'show': - $config['where']['id'] = $p['id']; - break; - case 'store': - break; - case 'update': - $config['where']['id'] = $p['id']; - break; - case 'destroy': - $config['where']['id'] = $p['id']; - break; - case 'logs': - $config['where']['instance_id'] = $p['instance_id']; - $config['order']['id'] = 'desc'; - break; - } - - return $config; - } - - - public function serviceApprove(Request $request) - { - $param = $request->all(); - $appro = new \app\common\utils\approval\service\ApprovalFlowService(); - return $appro->approve($param['instance_id'], $request->user->uid, $param['action'], $param['comment']); - } - - - public function serviceLogs(Request $request) - { - $config = $this->buildQueryConfig($request, 'logs'); - $item = $this->logicListAll($config); - return $this->postProcess('Logs', $item); - } -} \ No newline at end of file diff --git a/app/crm/service/StockOrdersService.php b/app/crm/service/StockOrdersService.php index 48627a0..9026af3 100644 --- a/app/crm/service/StockOrdersService.php +++ b/app/crm/service/StockOrdersService.php @@ -13,8 +13,8 @@ use support\Request; use app\common\model\User; use support\Db; use support\Model; -use app\admin\model\ApprovalInstances; -use app\admin\model\ApprovalRecords; +use app\common\model\ApprovalInstances; +use app\common\model\ApprovalRecords; use support\exception\BusinessException; class StockOrdersService diff --git a/composer.json b/composer.json index fcc2089..65fd08b 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,6 @@ "webman/console": "^2.1", "vlucas/phpdotenv": "^5.6", "firebase/php-jwt": "^6.11", - "league/oauth2-server": "^9.2", "topthink/think-validate": "^3.0", "shopwwi/webman-filesystem": "1.1", "shopwwi/filesystem-oss": "^1.0", diff --git a/composer.lock b/composer.lock index 2272db8..feaeb5a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "68e74d2aef3a2f7f8163bfaf65431cb2", + "content-hash": "4914e483b0c6fc599378c91d2eab17cf", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -265,73 +265,6 @@ ], "time": "2024-11-12T16:29:46+00:00" }, - { - "name": "defuse/php-encryption", - "version": "v2.4.0", - "source": { - "type": "git", - "url": "https://github.com/defuse/php-encryption.git", - "reference": "f53396c2d34225064647a05ca76c1da9d99e5828" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/defuse/php-encryption/zipball/f53396c2d34225064647a05ca76c1da9d99e5828", - "reference": "f53396c2d34225064647a05ca76c1da9d99e5828", - "shasum": "" - }, - "require": { - "ext-openssl": "*", - "paragonie/random_compat": ">= 2", - "php": ">=5.6.0" - }, - "require-dev": { - "phpunit/phpunit": "^5|^6|^7|^8|^9|^10", - "yoast/phpunit-polyfills": "^2.0.0" - }, - "bin": [ - "bin/generate-defuse-key" - ], - "type": "library", - "autoload": { - "psr-4": { - "Defuse\\Crypto\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Hornby", - "email": "taylor@defuse.ca", - "homepage": "https://defuse.ca/" - }, - { - "name": "Scott Arciszewski", - "email": "info@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "Secure PHP Encryption Library", - "keywords": [ - "aes", - "authenticated encryption", - "cipher", - "crypto", - "cryptography", - "encrypt", - "encryption", - "openssl", - "security", - "symmetric key cryptography" - ], - "support": { - "issues": "https://github.com/defuse/php-encryption/issues", - "source": "https://github.com/defuse/php-encryption/tree/v2.4.0" - }, - "time": "2023-06-19T06:10:36+00:00" - }, { "name": "doctrine/inflector", "version": "2.0.10", @@ -1931,202 +1864,6 @@ }, "time": "2025-03-19T13:51:03+00:00" }, - { - "name": "lcobucci/clock", - "version": "3.3.1", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/clock.git", - "reference": "db3713a61addfffd615b79bf0bc22f0ccc61b86b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/db3713a61addfffd615b79bf0bc22f0ccc61b86b", - "reference": "db3713a61addfffd615b79bf0bc22f0ccc61b86b", - "shasum": "" - }, - "require": { - "php": "~8.2.0 || ~8.3.0 || ~8.4.0", - "psr/clock": "^1.0" - }, - "provide": { - "psr/clock-implementation": "1.0" - }, - "require-dev": { - "infection/infection": "^0.29", - "lcobucci/coding-standard": "^11.1.0", - "phpstan/extension-installer": "^1.3.1", - "phpstan/phpstan": "^1.10.25", - "phpstan/phpstan-deprecation-rules": "^1.1.3", - "phpstan/phpstan-phpunit": "^1.3.13", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^11.3.6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Lcobucci\\Clock\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Luís Cobucci", - "email": "lcobucci@gmail.com" - } - ], - "description": "Yet another clock abstraction", - "support": { - "issues": "https://github.com/lcobucci/clock/issues", - "source": "https://github.com/lcobucci/clock/tree/3.3.1" - }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], - "time": "2024-09-24T20:45:14+00:00" - }, - { - "name": "lcobucci/jwt", - "version": "5.5.0", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/jwt.git", - "reference": "a835af59b030d3f2967725697cf88300f579088e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/jwt/zipball/a835af59b030d3f2967725697cf88300f579088e", - "reference": "a835af59b030d3f2967725697cf88300f579088e", - "shasum": "" - }, - "require": { - "ext-openssl": "*", - "ext-sodium": "*", - "php": "~8.2.0 || ~8.3.0 || ~8.4.0", - "psr/clock": "^1.0" - }, - "require-dev": { - "infection/infection": "^0.29", - "lcobucci/clock": "^3.2", - "lcobucci/coding-standard": "^11.0", - "phpbench/phpbench": "^1.2", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.10.7", - "phpstan/phpstan-deprecation-rules": "^1.1.3", - "phpstan/phpstan-phpunit": "^1.3.10", - "phpstan/phpstan-strict-rules": "^1.5.0", - "phpunit/phpunit": "^11.1" - }, - "suggest": { - "lcobucci/clock": ">= 3.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "Lcobucci\\JWT\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Luís Cobucci", - "email": "lcobucci@gmail.com", - "role": "Developer" - } - ], - "description": "A simple library to work with JSON Web Token and JSON Web Signature", - "keywords": [ - "JWS", - "jwt" - ], - "support": { - "issues": "https://github.com/lcobucci/jwt/issues", - "source": "https://github.com/lcobucci/jwt/tree/5.5.0" - }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], - "time": "2025-01-26T21:29:45+00:00" - }, - { - "name": "league/event", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/event.git", - "reference": "ec38ff7ea10cad7d99a79ac937fbcffb9334c210" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/event/zipball/ec38ff7ea10cad7d99a79ac937fbcffb9334c210", - "reference": "ec38ff7ea10cad7d99a79ac937fbcffb9334c210", - "shasum": "" - }, - "require": { - "php": ">=7.2.0", - "psr/event-dispatcher": "^1.0" - }, - "provide": { - "psr/event-dispatcher-implementation": "1.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", - "phpstan/phpstan": "^0.12.45", - "phpunit/phpunit": "^8.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Event\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frenky.net" - } - ], - "description": "Event package", - "keywords": [ - "emitter", - "event", - "listener" - ], - "support": { - "issues": "https://github.com/thephpleague/event/issues", - "source": "https://github.com/thephpleague/event/tree/3.0.3" - }, - "time": "2024-09-04T16:06:53+00:00" - }, { "name": "league/flysystem", "version": "3.29.0", @@ -2333,276 +2070,6 @@ ], "time": "2024-01-28T23:22:08+00:00" }, - { - "name": "league/oauth2-server", - "version": "9.2.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/oauth2-server.git", - "reference": "00323013403e1a1e0f424affafca56c28b60c22c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/00323013403e1a1e0f424affafca56c28b60c22c", - "reference": "00323013403e1a1e0f424affafca56c28b60c22c", - "shasum": "" - }, - "require": { - "defuse/php-encryption": "^2.4", - "ext-json": "*", - "ext-openssl": "*", - "lcobucci/clock": "^2.3 || ^3.0", - "lcobucci/jwt": "^5.0", - "league/event": "^3.0", - "league/uri": "^7.0", - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", - "psr/http-message": "^2.0", - "psr/http-server-middleware": "^1.0" - }, - "replace": { - "league/oauth2server": "*", - "lncd/oauth2": "*" - }, - "require-dev": { - "laminas/laminas-diactoros": "^3.5", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpstan/extension-installer": "^1.3.1", - "phpstan/phpstan": "^1.12", - "phpstan/phpstan-deprecation-rules": "^1.1.4", - "phpstan/phpstan-phpunit": "^1.3.15", - "phpstan/phpstan-strict-rules": "^1.5.2", - "phpunit/phpunit": "^9.6.21", - "roave/security-advisories": "dev-master", - "slevomat/coding-standard": "^8.14.1", - "squizlabs/php_codesniffer": "^3.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "League\\OAuth2\\Server\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alex Bilbie", - "email": "hello@alexbilbie.com", - "homepage": "http://www.alexbilbie.com", - "role": "Developer" - }, - { - "name": "Andy Millington", - "email": "andrew@noexceptions.io", - "homepage": "https://www.noexceptions.io", - "role": "Developer" - } - ], - "description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.", - "homepage": "https://oauth2.thephpleague.com/", - "keywords": [ - "Authentication", - "api", - "auth", - "authorisation", - "authorization", - "oauth", - "oauth 2", - "oauth 2.0", - "oauth2", - "protect", - "resource", - "secure", - "server" - ], - "support": { - "issues": "https://github.com/thephpleague/oauth2-server/issues", - "source": "https://github.com/thephpleague/oauth2-server/tree/9.2.0" - }, - "funding": [ - { - "url": "https://github.com/sephster", - "type": "github" - } - ], - "time": "2025-02-15T00:49:10+00:00" - }, - { - "name": "league/uri", - "version": "7.5.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri.git", - "reference": "81fb5145d2644324614cc532b28efd0215bda430" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/81fb5145d2644324614cc532b28efd0215bda430", - "reference": "81fb5145d2644324614cc532b28efd0215bda430", - "shasum": "" - }, - "require": { - "league/uri-interfaces": "^7.5", - "php": "^8.1" - }, - "conflict": { - "league/uri-schemes": "^1.0" - }, - "suggest": { - "ext-bcmath": "to improve IPV4 host parsing", - "ext-fileinfo": "to create Data URI from file contennts", - "ext-gmp": "to improve IPV4 host parsing", - "ext-intl": "to handle IDN host with the best performance", - "jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain", - "league/uri-components": "Needed to easily manipulate URI objects components", - "php-64bit": "to improve IPV4 host parsing", - "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "URI manipulation library", - "homepage": "https://uri.thephpleague.com", - "keywords": [ - "data-uri", - "file-uri", - "ftp", - "hostname", - "http", - "https", - "middleware", - "parse_str", - "parse_url", - "psr-7", - "query-string", - "querystring", - "rfc3986", - "rfc3987", - "rfc6570", - "uri", - "uri-template", - "url", - "ws" - ], - "support": { - "docs": "https://uri.thephpleague.com", - "forum": "https://thephpleague.slack.com", - "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri/tree/7.5.1" - }, - "funding": [ - { - "url": "https://github.com/sponsors/nyamsprod", - "type": "github" - } - ], - "time": "2024-12-08T08:40:02+00:00" - }, - { - "name": "league/uri-interfaces", - "version": "7.5.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", - "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", - "shasum": "" - }, - "require": { - "ext-filter": "*", - "php": "^8.1", - "psr/http-factory": "^1", - "psr/http-message": "^1.1 || ^2.0" - }, - "suggest": { - "ext-bcmath": "to improve IPV4 host parsing", - "ext-gmp": "to improve IPV4 host parsing", - "ext-intl": "to handle IDN host with the best performance", - "php-64bit": "to improve IPV4 host parsing", - "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "Common interfaces and classes for URI representation and interaction", - "homepage": "https://uri.thephpleague.com", - "keywords": [ - "data-uri", - "file-uri", - "ftp", - "hostname", - "http", - "https", - "parse_str", - "parse_url", - "psr-7", - "query-string", - "querystring", - "rfc3986", - "rfc3987", - "rfc6570", - "uri", - "url", - "ws" - ], - "support": { - "docs": "https://uri.thephpleague.com", - "forum": "https://thephpleague.slack.com", - "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri-interfaces/tree/7.5.0" - }, - "funding": [ - { - "url": "https://github.com/sponsors/nyamsprod", - "type": "github" - } - ], - "time": "2024-12-08T08:18:47+00:00" - }, { "name": "maennchen/zipstream-php", "version": "3.1.2", @@ -3950,119 +3417,6 @@ }, "time": "2023-04-04T09:54:51+00:00" }, - { - "name": "psr/http-server-handler", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-server-handler.git", - "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/84c4fb66179be4caaf8e97bd239203245302e7d4", - "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4", - "shasum": "" - }, - "require": { - "php": ">=7.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Server\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP server-side request handler", - "keywords": [ - "handler", - "http", - "http-interop", - "psr", - "psr-15", - "psr-7", - "request", - "response", - "server" - ], - "support": { - "source": "https://github.com/php-fig/http-server-handler/tree/1.0.2" - }, - "time": "2023-04-10T20:06:20+00:00" - }, - { - "name": "psr/http-server-middleware", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-server-middleware.git", - "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/c1481f747daaa6a0782775cd6a8c26a1bf4a3829", - "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829", - "shasum": "" - }, - "require": { - "php": ">=7.0", - "psr/http-message": "^1.0 || ^2.0", - "psr/http-server-handler": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Server\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP server-side middleware", - "keywords": [ - "http", - "http-interop", - "middleware", - "psr", - "psr-15", - "psr-7", - "request", - "response" - ], - "support": { - "issues": "https://github.com/php-fig/http-server-middleware/issues", - "source": "https://github.com/php-fig/http-server-middleware/tree/1.0.2" - }, - "time": "2023-04-11T06:14:47+00:00" - }, { "name": "psr/log", "version": "3.0.2", diff --git a/config/route.php b/config/route.php index 64179d8..887c683 100644 --- a/config/route.php +++ b/config/route.php @@ -315,6 +315,8 @@ Route::group('/admin', function () { Route::any('/list', [app\admin\controller\ApprovalRecordsController::class, 'index']); Route::any('/logs', [app\admin\controller\ApprovalRecordsController::class, 'logs']); Route::any('/action', [app\admin\controller\ApprovalRecordsController::class, 'approve']); + + Route::any('/todo', [app\admin\controller\ApprovalRecordsController::class, 'todo']); }); Route::group('/stock/order', function () { @@ -430,6 +432,8 @@ Route::group('/crm', function () { Route::any('/list', [app\crm\controller\ApprovalRecordsController::class, 'index']); Route::any('/logs', [app\crm\controller\ApprovalRecordsController::class, 'logs']); Route::any('/action', [app\crm\controller\ApprovalRecordsController::class, 'approve']); + + Route::any('/todo', [app\admin\controller\ApprovalRecordsController::class, 'todo']); }); // 汽车颜色 diff --git a/webman b/webman old mode 100755 new mode 100644 index 3f55062..c853676 --- a/webman +++ b/webman @@ -1,71 +1,71 @@ -#!/usr/bin/env php -load(); - } else { - Dotenv::createMutable(run_path())->load(); - } -} - -$appConfig = require $appConfigFile; -if ($timezone = $appConfig['default_timezone'] ?? '') { - date_default_timezone_set($timezone); -} - -if ($errorReporting = $appConfig['error_reporting'] ?? '') { - error_reporting($errorReporting); -} - -if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) { - require_once __DIR__ . '/support/bootstrap.php'; -} else { - if (class_exists('Support\App')) { - Support\App::loadAllConfig(['route']); - } else { - Config::reload(config_path(), ['route', 'container']); - } -} - -$cli = new Command(); -$cli->setName('webman cli'); -$cli->installInternalCommands(); -if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) { - $cli->installCommands($command_path); -} - -foreach (config('plugin', []) as $firm => $projects) { - if (isset($projects['app'])) { - foreach (['', '/app'] as $app) { - if ($command_str = Util::guessPath(base_path() . "/plugin/$firm{$app}", 'command')) { - $command_path = base_path() . "/plugin/$firm{$app}/$command_str"; - $cli->installCommands($command_path, "plugin\\$firm" . str_replace('/', '\\', $app) . "\\$command_str"); - } - } - } - foreach ($projects as $name => $project) { - if (!is_array($project)) { - continue; - } - $project['command'] ??= []; - array_walk($project['command'], [$cli, 'createCommandInstance']); - } -} - -$cli->run(); +#!/usr/bin/env php +load(); + } else { + Dotenv::createMutable(run_path())->load(); + } +} + +$appConfig = require $appConfigFile; +if ($timezone = $appConfig['default_timezone'] ?? '') { + date_default_timezone_set($timezone); +} + +if ($errorReporting = $appConfig['error_reporting'] ?? '') { + error_reporting($errorReporting); +} + +if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) { + require_once __DIR__ . '/support/bootstrap.php'; +} else { + if (class_exists('Support\App')) { + Support\App::loadAllConfig(['route']); + } else { + Config::reload(config_path(), ['route', 'container']); + } +} + +$cli = new Command(); +$cli->setName('webman cli'); +$cli->installInternalCommands(); +if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) { + $cli->installCommands($command_path); +} + +foreach (config('plugin', []) as $firm => $projects) { + if (isset($projects['app'])) { + foreach (['', '/app'] as $app) { + if ($command_str = Util::guessPath(base_path() . "/plugin/$firm{$app}", 'command')) { + $command_path = base_path() . "/plugin/$firm{$app}/$command_str"; + $cli->installCommands($command_path, "plugin\\$firm" . str_replace('/', '\\', $app) . "\\$command_str"); + } + } + } + foreach ($projects as $name => $project) { + if (!is_array($project)) { + continue; + } + $project['command'] ??= []; + array_walk($project['command'], [$cli, 'createCommandInstance']); + } +} + +$cli->run();