From 989bf299b51a90efc5a4d301ff094664328911ac Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 27 Aug 2025 15:31:25 +0800 Subject: [PATCH 01/20] 1 --- app/admin/controller/SysDictController.php | 33 +++ .../controller/SysDictItemController.php | 33 +++ app/admin/logic/SysDictItemLogic.php | 17 ++ app/admin/logic/SysDictLogic.php | 17 ++ app/admin/service/SysDictItemService.php | 31 +++ app/admin/service/SysDictService.php | 81 +++++++ app/admin/validate/SysDictItemValidate.php | 29 +++ app/admin/validate/SysDictValidate.php | 29 +++ app/common/model/SysDict.php | 59 +++++ app/common/model/SysDictItem.php | 59 +++++ app/controller/IndexController.php | 20 +- .../redis/InquiryToCrmNew_BACKUP_5243.php | 218 ++++++++++++++++++ app/queue/redis/InquiryToCrmNew_BASE_5243.php | 0 .../redis/InquiryToCrmNew_LOCAL_5243.php | 204 ++++++++++++++++ .../redis/InquiryToCrmNew_REMOTE_5243.php | 207 +++++++++++++++++ config/route.php | 17 ++ 16 files changed, 1044 insertions(+), 10 deletions(-) create mode 100644 app/admin/controller/SysDictController.php create mode 100644 app/admin/controller/SysDictItemController.php create mode 100644 app/admin/logic/SysDictItemLogic.php create mode 100644 app/admin/logic/SysDictLogic.php create mode 100644 app/admin/service/SysDictItemService.php create mode 100644 app/admin/service/SysDictService.php create mode 100644 app/admin/validate/SysDictItemValidate.php create mode 100644 app/admin/validate/SysDictValidate.php create mode 100644 app/common/model/SysDict.php create mode 100644 app/common/model/SysDictItem.php create mode 100644 app/queue/redis/InquiryToCrmNew_BACKUP_5243.php create mode 100644 app/queue/redis/InquiryToCrmNew_BASE_5243.php create mode 100644 app/queue/redis/InquiryToCrmNew_LOCAL_5243.php create mode 100644 app/queue/redis/InquiryToCrmNew_REMOTE_5243.php diff --git a/app/admin/controller/SysDictController.php b/app/admin/controller/SysDictController.php new file mode 100644 index 0000000..6e54cd7 --- /dev/null +++ b/app/admin/controller/SysDictController.php @@ -0,0 +1,33 @@ +service = new SysDictService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/admin/controller/SysDictItemController.php b/app/admin/controller/SysDictItemController.php new file mode 100644 index 0000000..9c92f6c --- /dev/null +++ b/app/admin/controller/SysDictItemController.php @@ -0,0 +1,33 @@ +service = new SysDictItemService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/admin/logic/SysDictItemLogic.php b/app/admin/logic/SysDictItemLogic.php new file mode 100644 index 0000000..99db163 --- /dev/null +++ b/app/admin/logic/SysDictItemLogic.php @@ -0,0 +1,17 @@ +validator; + } +} \ No newline at end of file diff --git a/app/admin/service/SysDictService.php b/app/admin/service/SysDictService.php new file mode 100644 index 0000000..82c6be6 --- /dev/null +++ b/app/admin/service/SysDictService.php @@ -0,0 +1,81 @@ +validator; + } + + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'index'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['dict_name','dict_code','description','whatsapp','contacts'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + + // ====== ====== 关联 ====== ====== + $config['with']['sysDictItem'][] = 'item_label'; + $config['with']['sysDictItem'][] = 'item_value'; + break; + case 'show': + $config['where']['id'] = $p['id']; + // ====== ====== 关联 ====== ====== + $config['with']['sysDictItem'][] = 'item_label'; + $config['with']['sysDictItem'][] = 'item_value'; + break; + case 'update': + case 'destroy': + $config['where']['id'] = $p['id']; + break; + case 'store': + break; + } + + return $config; + } +} \ No newline at end of file diff --git a/app/admin/validate/SysDictItemValidate.php b/app/admin/validate/SysDictItemValidate.php new file mode 100644 index 0000000..2d4ad58 --- /dev/null +++ b/app/admin/validate/SysDictItemValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/admin/validate/SysDictValidate.php b/app/admin/validate/SysDictValidate.php new file mode 100644 index 0000000..bdb6d1e --- /dev/null +++ b/app/admin/validate/SysDictValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/SysDict.php b/app/common/model/SysDict.php new file mode 100644 index 0000000..7ef5a62 --- /dev/null +++ b/app/common/model/SysDict.php @@ -0,0 +1,59 @@ +hasMany(SysDictItem::class, 'dict_id', 'id'); + } +} \ No newline at end of file diff --git a/app/common/model/SysDictItem.php b/app/common/model/SysDictItem.php new file mode 100644 index 0000000..f53a7a9 --- /dev/null +++ b/app/common/model/SysDictItem.php @@ -0,0 +1,59 @@ +belongsTo(SysDict::class, 'dict_id', 'id'); + } +} \ No newline at end of file diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php index ba87d98..e6a53d7 100644 --- a/app/controller/IndexController.php +++ b/app/controller/IndexController.php @@ -77,26 +77,26 @@ class IndexController { $options = [ 'controller' => [ - 'module' => 'common', - 'name' => 'message_notifications' + 'module' => 'admin', + 'name' => 'sys_dict_item' ], 'model' => [ 'module' => 'common', - 'name' => 'message_notifications' + 'name' => 'sys_dict_item' ], 'service' => [ - 'module' => 'common', - 'name' => 'message_notifications' + 'module' => 'admin', + 'name' => 'sys_dict_item' ], 'logic' => [ - 'module' => 'common', - 'name' => 'message_notifications' + 'module' => 'admin', + 'name' => 'sys_dict_item' ], 'validate' => [ - 'module' => 'common', - 'name' => 'message_notifications' + 'module' => 'admin', + 'name' => 'sys_dict_item' ], - 'table' => 'message_notifications' + 'table' => 'sys_dict_item' ]; $result = (new Generate($options))->doGenerate(); diff --git a/app/queue/redis/InquiryToCrmNew_BACKUP_5243.php b/app/queue/redis/InquiryToCrmNew_BACKUP_5243.php new file mode 100644 index 0000000..d63b683 --- /dev/null +++ b/app/queue/redis/InquiryToCrmNew_BACKUP_5243.php @@ -0,0 +1,218 @@ +where('id', $data['id'])->first(); + + // 无论添加 或 更新,询单必然要存在 + if (!$info) { + throw new BusinessException('询盘不存在:' . $data['id']); + } + + if ($info->status == 0 && $info->recipient == 0) { + // 如果询单未发、未分,则不与crm同步,不做任何处理 + return true; + } + + // 更改库信息 + $this->syncCustomer($info); + } catch (\Throwable $th) { + throw $th; + } + } + + public function pushWs($title, $content, $recipient = []) + { + $wsdata = [ + 'sender_id' => 0, + 'sender_type' => 'system', + 'title' => $title, + 'content' => $content, + 'scene' => 1, + 'recipient' => $recipient + ]; + // 异步推送 + \Webman\RedisQueue\Redis::send('notice', $wsdata); + } + + public function syncCustomer(Model $info) + { + $uInfo = $this->recipientInfo($info); + $crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first(); + if ($crmCustomerInfo) { + + // 消息推送 + if ($info->status == 2 && empty($crmCustomerInfo->user_id)) { + // $notice = '分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } else { + if ($info->status == 2 && $crmCustomerInfo->user_id == $info->recipient) { + // $notice = '更新'; + $title = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理'; + $content = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } else { + // $notice = '重新分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } + } + + $udata = [ +<<<<<<< HEAD + 'corp_abbr' => $uInfo['corpId'], +======= + 'corp_id' => $uInfo['corpId'], +>>>>>>> feature/distinct + 'user_id' => $info->recipient, + 'channel_id' => $info->channel, + 'country_id' => $info->country, + 'magnitude' => $info->quality, + 'email' => $info->email, + 'phone' => $info->tel, + 'WhatsApp' => $info->whatsapp, + 'contacts' => $info->contacts, + 'desc_collect' => $info->content, + ]; + if (!$crmCustomerInfo->update($udata)) { + throw new BusinessException('同步失败,更新客户线索失败'); + } + } else { + $crmCustomer = new CrmCustomer(); + $crmCustomer->sn = $info->order_no; +<<<<<<< HEAD + $crmCustomer->corp_abbr = $uInfo['corpId']; +======= + $crmCustomer->corp_id = $uInfo['corpId']; +>>>>>>> feature/distinct + $crmCustomer->user_id = $uInfo['recipient']; + $crmCustomer->type = 1; + $crmCustomer->channel_id = $info->channel; + $crmCustomer->country_id = $info->country; + $crmCustomer->magnitude = $info->quality; + $crmCustomer->email = $info->email; + $crmCustomer->phone = $info->tel; + $crmCustomer->WhatsApp = $info->whatsapp; + $crmCustomer->contacts = $info->contacts; + $crmCustomer->desc_collect = $info->content; + $crmCustomer->enter_user_id = $info->enter_user_id; + $crmCustomer->obtain = time(); +<<<<<<< HEAD +======= + if(empty($uInfo['recipient'])){ + $crmCustomer->deleted_at = time(); + } +>>>>>>> feature/distinct + // 修改同步CRM状态 + $info->sync_crm = 1; + // 保存 + if (!$crmCustomer->save() || !$info->save()) { + throw new BusinessException('同步失败,创建客户线索失败'); + } + + // 消息推送 + if ($info->status == 1) { + // $notice = '发布'; + $title = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布'; + $content = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content); + } + + if ($info->status == 2) { + // $notice = '分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } + } + return true; + } + + public function recipientInfo(Model $info) + { + $recipient = 0; + $corpId = 0; + $uinfo = null; + if (!empty($info->recipient)) { + $recipient = $info->recipient; + $uinfo = User::where('id', $info->recipient)->first(); + if ($uinfo) { + $corpId = $uinfo->corp_id; + } + } + return [ + 'recipient' => $recipient, + 'corpId' => $corpId, + 'uinfo' => $uinfo + ]; + } + + // 消费失败回调 + /* + $package = [ + 'id' => 1357277951, // 消息ID + 'time' => 1709170510, // 消息时间 + 'delay' => 0, // 延迟时间 + 'attempts' => 2, // 消费次数 + 'queue' => 'send-mail', // 队列名 + 'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容 + 'max_attempts' => 5, // 最大重试次数 + 'error' => '错误信息' // 错误信息 + ] + */ + public function onConsumeFailure(\Throwable $e, $package) + { + echo "consume failure\n"; + echo $e->getMessage() . "\n"; + // 无需反序列化 + var_export($package); + } +} \ No newline at end of file diff --git a/app/queue/redis/InquiryToCrmNew_BASE_5243.php b/app/queue/redis/InquiryToCrmNew_BASE_5243.php new file mode 100644 index 0000000..e69de29 diff --git a/app/queue/redis/InquiryToCrmNew_LOCAL_5243.php b/app/queue/redis/InquiryToCrmNew_LOCAL_5243.php new file mode 100644 index 0000000..a350c7e --- /dev/null +++ b/app/queue/redis/InquiryToCrmNew_LOCAL_5243.php @@ -0,0 +1,204 @@ +where('id', $data['id'])->first(); + + // 无论添加 或 更新,询单必然要存在 + if (!$info) { + throw new BusinessException('询盘不存在:' . $data['id']); + } + + if ($info->status == 0 && $info->recipient == 0) { + // 如果询单未发、未分,则不与crm同步,不做任何处理 + return true; + } + + // 更改库信息 + $this->syncCustomer($info); + } catch (\Throwable $th) { + throw $th; + } + } + + public function pushWs($title, $content, $recipient = []) + { + $wsdata = [ + 'sender_id' => 0, + 'sender_type' => 'system', + 'title' => $title, + 'content' => $content, + 'scene' => 1, + 'recipient' => $recipient + ]; + // 异步推送 + \Webman\RedisQueue\Redis::send('notice', $wsdata); + } + + public function syncCustomer(Model $info) + { + $uInfo = $this->recipientInfo($info); + $crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first(); + if ($crmCustomerInfo) { + + // 消息推送 + if ($info->status == 2 && empty($crmCustomerInfo->user_id)) { + // $notice = '分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } else { + if ($info->status == 2 && $crmCustomerInfo->user_id == $info->recipient) { + // $notice = '更新'; + $title = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理'; + $content = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } else { + // $notice = '重新分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } + } + + $udata = [ + 'corp_abbr' => $uInfo['corpId'], + 'user_id' => $info->recipient, + 'channel_id' => $info->channel, + 'country_id' => $info->country, + 'magnitude' => $info->quality, + 'email' => $info->email, + 'phone' => $info->tel, + 'WhatsApp' => $info->whatsapp, + 'contacts' => $info->contacts, + 'desc_collect' => $info->content, + ]; + if (!$crmCustomerInfo->update($udata)) { + throw new BusinessException('同步失败,更新客户线索失败'); + } + } else { + $crmCustomer = new CrmCustomer(); + $crmCustomer->sn = $info->order_no; + $crmCustomer->corp_abbr = $uInfo['corpId']; + $crmCustomer->user_id = $uInfo['recipient']; + $crmCustomer->type = 1; + $crmCustomer->channel_id = $info->channel; + $crmCustomer->country_id = $info->country; + $crmCustomer->magnitude = $info->quality; + $crmCustomer->email = $info->email; + $crmCustomer->phone = $info->tel; + $crmCustomer->WhatsApp = $info->whatsapp; + $crmCustomer->contacts = $info->contacts; + $crmCustomer->desc_collect = $info->content; + $crmCustomer->enter_user_id = $info->enter_user_id; + $crmCustomer->obtain = time(); + // 修改同步CRM状态 + $info->sync_crm = 1; + // 保存 + if (!$crmCustomer->save() || !$info->save()) { + throw new BusinessException('同步失败,创建客户线索失败'); + } + + // 消息推送 + if ($info->status == 1) { + // $notice = '发布'; + $title = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布'; + $content = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content); + } + + if ($info->status == 2) { + // $notice = '分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } + } + return true; + } + + public function recipientInfo(Model $info) + { + $recipient = 0; + $corpId = 0; + $uinfo = null; + if (!empty($info->recipient)) { + $recipient = $info->recipient; + $uinfo = User::where('id', $info->recipient)->first(); + if ($uinfo) { + $corpId = $uinfo->corp_id; + } + } + return [ + 'recipient' => $recipient, + 'corpId' => $corpId, + 'uinfo' => $uinfo + ]; + } + + // 消费失败回调 + /* + $package = [ + 'id' => 1357277951, // 消息ID + 'time' => 1709170510, // 消息时间 + 'delay' => 0, // 延迟时间 + 'attempts' => 2, // 消费次数 + 'queue' => 'send-mail', // 队列名 + 'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容 + 'max_attempts' => 5, // 最大重试次数 + 'error' => '错误信息' // 错误信息 + ] + */ + public function onConsumeFailure(\Throwable $e, $package) + { + echo "consume failure\n"; + echo $e->getMessage() . "\n"; + // 无需反序列化 + var_export($package); + } +} \ No newline at end of file diff --git a/app/queue/redis/InquiryToCrmNew_REMOTE_5243.php b/app/queue/redis/InquiryToCrmNew_REMOTE_5243.php new file mode 100644 index 0000000..075deda --- /dev/null +++ b/app/queue/redis/InquiryToCrmNew_REMOTE_5243.php @@ -0,0 +1,207 @@ +where('id', $data['id'])->first(); + + // 无论添加 或 更新,询单必然要存在 + if (!$info) { + throw new BusinessException('询盘不存在:' . $data['id']); + } + + if ($info->status == 0 && $info->recipient == 0) { + // 如果询单未发、未分,则不与crm同步,不做任何处理 + return true; + } + + // 更改库信息 + $this->syncCustomer($info); + } catch (\Throwable $th) { + throw $th; + } + } + + public function pushWs($title, $content, $recipient = []) + { + $wsdata = [ + 'sender_id' => 0, + 'sender_type' => 'system', + 'title' => $title, + 'content' => $content, + 'scene' => 1, + 'recipient' => $recipient + ]; + // 异步推送 + \Webman\RedisQueue\Redis::send('notice', $wsdata); + } + + public function syncCustomer(Model $info) + { + $uInfo = $this->recipientInfo($info); + $crmCustomerInfo = CrmCustomer::where('sn', $info->order_no)->first(); + if ($crmCustomerInfo) { + + // 消息推送 + if ($info->status == 2 && empty($crmCustomerInfo->user_id)) { + // $notice = '分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } else { + if ($info->status == 2 && $crmCustomerInfo->user_id == $info->recipient) { + // $notice = '更新'; + $title = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理'; + $content = '[询单·更新] 客户线索' . $info->order_no . '有新的调整,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } else { + // $notice = '重新分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } + } + + $udata = [ + 'corp_id' => $uInfo['corpId'], + 'user_id' => $info->recipient, + 'channel_id' => $info->channel, + 'country_id' => $info->country, + 'magnitude' => $info->quality, + 'email' => $info->email, + 'phone' => $info->tel, + 'WhatsApp' => $info->whatsapp, + 'contacts' => $info->contacts, + 'desc_collect' => $info->content, + ]; + if (!$crmCustomerInfo->update($udata)) { + throw new BusinessException('同步失败,更新客户线索失败'); + } + } else { + $crmCustomer = new CrmCustomer(); + $crmCustomer->sn = $info->order_no; + $crmCustomer->corp_id = $uInfo['corpId']; + $crmCustomer->user_id = $uInfo['recipient']; + $crmCustomer->type = 1; + $crmCustomer->channel_id = $info->channel; + $crmCustomer->country_id = $info->country; + $crmCustomer->magnitude = $info->quality; + $crmCustomer->email = $info->email; + $crmCustomer->phone = $info->tel; + $crmCustomer->WhatsApp = $info->whatsapp; + $crmCustomer->contacts = $info->contacts; + $crmCustomer->desc_collect = $info->content; + $crmCustomer->enter_user_id = $info->enter_user_id; + $crmCustomer->obtain = time(); + if(empty($uInfo['recipient'])){ + $crmCustomer->deleted_at = time(); + } + // 修改同步CRM状态 + $info->sync_crm = 1; + // 保存 + if (!$crmCustomer->save() || !$info->save()) { + throw new BusinessException('同步失败,创建客户线索失败'); + } + + // 消息推送 + if ($info->status == 1) { + // $notice = '发布'; + $title = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布'; + $content = '[询单·公海] 新的客户线索【' . $info->order_no . '】发布'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content); + } + + if ($info->status == 2) { + // $notice = '分配'; + $title = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $content = '[询单·分配] 新的客户线索【' . $info->order_no . '】,请及时处理'; + $recipient = [$info->recipient]; + $this->pushWs($title, $content, $recipient); + } + } + return true; + } + + public function recipientInfo(Model $info) + { + $recipient = 0; + $corpId = 0; + $uinfo = null; + if (!empty($info->recipient)) { + $recipient = $info->recipient; + $uinfo = User::where('id', $info->recipient)->first(); + if ($uinfo) { + $corpId = $uinfo->corp_id; + } + } + return [ + 'recipient' => $recipient, + 'corpId' => $corpId, + 'uinfo' => $uinfo + ]; + } + + // 消费失败回调 + /* + $package = [ + 'id' => 1357277951, // 消息ID + 'time' => 1709170510, // 消息时间 + 'delay' => 0, // 延迟时间 + 'attempts' => 2, // 消费次数 + 'queue' => 'send-mail', // 队列名 + 'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容 + 'max_attempts' => 5, // 最大重试次数 + 'error' => '错误信息' // 错误信息 + ] + */ + public function onConsumeFailure(\Throwable $e, $package) + { + echo "consume failure\n"; + echo $e->getMessage() . "\n"; + // 无需反序列化 + var_export($package); + } +} \ No newline at end of file diff --git a/config/route.php b/config/route.php index 86aa1a0..d8664fc 100644 --- a/config/route.php +++ b/config/route.php @@ -182,6 +182,23 @@ Route::group('/admin', function () { Route::any('/allocation', [app\crmAdmin\controller\CustomerController::class, 'allocation']); }); }); + + // 字典 + Route::group('/dict', function () { + Route::any('/list', [app\admin\controller\SysDictController::class, 'index']); + Route::any('/show', [app\admin\controller\SysDictController::class, 'show']); + Route::any('/store', [app\admin\controller\SysDictController::class, 'store']); + Route::any('/update', [app\admin\controller\SysDictController::class, 'update']); + Route::any('/destroy', [app\admin\controller\SysDictController::class, 'destroy']); + + Route::group('/item', function () { + Route::any('/list', [app\admin\controller\SysDictItemController::class, 'index']); + Route::any('/show', [app\admin\controller\SysDictItemController::class, 'show']); + Route::any('/store', [app\admin\controller\SysDictItemController::class, 'store']); + Route::any('/update', [app\admin\controller\SysDictItemController::class, 'update']); + Route::any('/destroy', [app\admin\controller\SysDictItemController::class, 'destroy']); + }); + }); }); From b751975e3f0d35464683f835a5c9bcff7a1d79c0 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 27 Aug 2025 16:43:30 +0800 Subject: [PATCH 02/20] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysDictController.php | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/SysDictController.php b/app/admin/controller/SysDictController.php index 6e54cd7..4fa9852 100644 --- a/app/admin/controller/SysDictController.php +++ b/app/admin/controller/SysDictController.php @@ -2,8 +2,10 @@ namespace app\admin\controller; use app\common\controller\BaseController; +use app\common\model\SysDictItem; use app\common\traits\crud\CrudControllerTrait; use app\admin\service\SysDictService; +use support\Request; class SysDictController extends BaseController { @@ -22,12 +24,26 @@ class SysDictController extends BaseController * @param array $data * @return array */ - // protected function indexFormat($data) - // { - // if (isset($data['created_at'])) - // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); - // if (isset($data['updated_at'])) - // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - // return $data; - // } + protected function indexFormat($data) + { + if (isset($data['sysDictItem'])) + $data['sysDictItem'] = SysDictItem::where('dict_id',$data['id'])->get(); + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + + return $data; + } + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + $data['sysDictItem'] = SysDictItem::where('dict_id',$data['id'])->get(); + return $data; + } } \ No newline at end of file From 280c26983f9ccfb88ac2c1903917a201f3ee3a19 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 27 Aug 2025 17:39:59 +0800 Subject: [PATCH 03/20] =?UTF-8?q?=E8=B4=A7=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SysCurrencyController.php | 52 ++++++++++++++++ app/admin/logic/SysCurrencyLogic.php | 17 ++++++ app/admin/service/SysCurrencyService.php | 61 +++++++++++++++++++ app/admin/service/SysDictItemService.php | 37 +++++++++++ app/admin/validate/SysCurrencyValidate.php | 29 +++++++++ app/common/model/SysCurrency.php | 49 +++++++++++++++ config/route.php | 9 +++ 7 files changed, 254 insertions(+) create mode 100644 app/admin/controller/SysCurrencyController.php create mode 100644 app/admin/logic/SysCurrencyLogic.php create mode 100644 app/admin/service/SysCurrencyService.php create mode 100644 app/admin/validate/SysCurrencyValidate.php create mode 100644 app/common/model/SysCurrency.php diff --git a/app/admin/controller/SysCurrencyController.php b/app/admin/controller/SysCurrencyController.php new file mode 100644 index 0000000..0e96169 --- /dev/null +++ b/app/admin/controller/SysCurrencyController.php @@ -0,0 +1,52 @@ +service = new SysCurrencyService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (isset($data['last_updated'])) + $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + return $data; + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (isset($data['last_updated'])) + $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/logic/SysCurrencyLogic.php b/app/admin/logic/SysCurrencyLogic.php new file mode 100644 index 0000000..e70b18c --- /dev/null +++ b/app/admin/logic/SysCurrencyLogic.php @@ -0,0 +1,17 @@ +validator; + } + + + /** + * 构造 CrudUtil 查询配置 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'default': + $config['order']['id'] = 'desc'; + case 'index': + break; + case 'show': + $config['where']['id'] = $p['id']; + break; + case 'store': + break; + case 'update': + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } +} \ No newline at end of file diff --git a/app/admin/service/SysDictItemService.php b/app/admin/service/SysDictItemService.php index a4d54e2..e9269f4 100644 --- a/app/admin/service/SysDictItemService.php +++ b/app/admin/service/SysDictItemService.php @@ -5,6 +5,7 @@ namespace app\admin\service; use app\admin\validate\SysDictItemValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\SysDictItem; +use support\Request; class SysDictItemService { @@ -28,4 +29,40 @@ class SysDictItemService { return new $this->validator; } + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'index'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + + $config['where']['dict_id'] = $p['id']; + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + break; + case 'show': + $config['where']['id'] = $p['id']; + break; + case 'update': + case 'destroy': + $config['where']['id'] = $p['id']; + break; + case 'store': + break; + } + + return $config; + } } \ No newline at end of file diff --git a/app/admin/validate/SysCurrencyValidate.php b/app/admin/validate/SysCurrencyValidate.php new file mode 100644 index 0000000..4aebb21 --- /dev/null +++ b/app/admin/validate/SysCurrencyValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/SysCurrency.php b/app/common/model/SysCurrency.php new file mode 100644 index 0000000..200a23b --- /dev/null +++ b/app/common/model/SysCurrency.php @@ -0,0 +1,49 @@ + Date: Thu, 28 Aug 2025 09:57:46 +0800 Subject: [PATCH 04/20] =?UTF-8?q?=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/BrandController.php | 48 ++++++++++++++++++ .../controller/BrandSeriesController.php | 48 ++++++++++++++++++ app/admin/controller/SysDictController.php | 7 ++- .../controller/SysDictItemController.php | 31 +++++++++--- app/admin/logic/BrandLogic.php | 17 +++++++ app/admin/logic/BrandSeriesLogic.php | 17 +++++++ app/admin/service/BrandSeriesService.php | 31 ++++++++++++ app/admin/service/BrandService.php | 31 ++++++++++++ app/admin/validate/BrandSeriesValidate.php | 29 +++++++++++ app/admin/validate/BrandValidate.php | 29 +++++++++++ app/common/model/Brand.php | 49 +++++++++++++++++++ app/common/model/BrandSeries.php | 49 +++++++++++++++++++ config/route.php | 18 +++++++ 13 files changed, 395 insertions(+), 9 deletions(-) create mode 100644 app/admin/controller/BrandController.php create mode 100644 app/admin/controller/BrandSeriesController.php create mode 100644 app/admin/logic/BrandLogic.php create mode 100644 app/admin/logic/BrandSeriesLogic.php create mode 100644 app/admin/service/BrandSeriesService.php create mode 100644 app/admin/service/BrandService.php create mode 100644 app/admin/validate/BrandSeriesValidate.php create mode 100644 app/admin/validate/BrandValidate.php create mode 100644 app/common/model/Brand.php create mode 100644 app/common/model/BrandSeries.php diff --git a/app/admin/controller/BrandController.php b/app/admin/controller/BrandController.php new file mode 100644 index 0000000..f917fa5 --- /dev/null +++ b/app/admin/controller/BrandController.php @@ -0,0 +1,48 @@ +service = new BrandService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/controller/BrandSeriesController.php b/app/admin/controller/BrandSeriesController.php new file mode 100644 index 0000000..c2d95f7 --- /dev/null +++ b/app/admin/controller/BrandSeriesController.php @@ -0,0 +1,48 @@ +service = new BrandSeriesService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/controller/SysDictController.php b/app/admin/controller/SysDictController.php index 4fa9852..0e0b8d7 100644 --- a/app/admin/controller/SysDictController.php +++ b/app/admin/controller/SysDictController.php @@ -35,14 +35,19 @@ class SysDictController extends BaseController return $data; } + /** - * 列表页数据格式化 + * 数据格式化 * * @param array $data * @return array */ protected function showFormat($data) { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); $data['sysDictItem'] = SysDictItem::where('dict_id',$data['id'])->get(); return $data; } diff --git a/app/admin/controller/SysDictItemController.php b/app/admin/controller/SysDictItemController.php index 9c92f6c..9262933 100644 --- a/app/admin/controller/SysDictItemController.php +++ b/app/admin/controller/SysDictItemController.php @@ -22,12 +22,27 @@ class SysDictItemController extends BaseController * @param array $data * @return array */ - // protected function indexFormat($data) - // { - // if (isset($data['created_at'])) - // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); - // if (isset($data['updated_at'])) - // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - // return $data; - // } + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } } \ No newline at end of file diff --git a/app/admin/logic/BrandLogic.php b/app/admin/logic/BrandLogic.php new file mode 100644 index 0000000..6b12364 --- /dev/null +++ b/app/admin/logic/BrandLogic.php @@ -0,0 +1,17 @@ +validator; + } +} \ No newline at end of file diff --git a/app/admin/service/BrandService.php b/app/admin/service/BrandService.php new file mode 100644 index 0000000..83af709 --- /dev/null +++ b/app/admin/service/BrandService.php @@ -0,0 +1,31 @@ +validator; + } +} \ No newline at end of file diff --git a/app/admin/validate/BrandSeriesValidate.php b/app/admin/validate/BrandSeriesValidate.php new file mode 100644 index 0000000..31e30e2 --- /dev/null +++ b/app/admin/validate/BrandSeriesValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/admin/validate/BrandValidate.php b/app/admin/validate/BrandValidate.php new file mode 100644 index 0000000..370728d --- /dev/null +++ b/app/admin/validate/BrandValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/Brand.php b/app/common/model/Brand.php new file mode 100644 index 0000000..22c4704 --- /dev/null +++ b/app/common/model/Brand.php @@ -0,0 +1,49 @@ + Date: Thu, 28 Aug 2025 11:12:27 +0800 Subject: [PATCH 05/20] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/BrandController.php | 5 +++ app/admin/controller/VehColorController.php | 33 ++++++++++++++ app/admin/logic/VehColorLogic.php | 17 +++++++ app/admin/service/VehColorService.php | 31 +++++++++++++ app/admin/validate/VehColorValidate.php | 29 ++++++++++++ app/common/model/VehColor.php | 49 +++++++++++++++++++++ config/route.php | 23 +++++++--- 7 files changed, 180 insertions(+), 7 deletions(-) create mode 100644 app/admin/controller/VehColorController.php create mode 100644 app/admin/logic/VehColorLogic.php create mode 100644 app/admin/service/VehColorService.php create mode 100644 app/admin/validate/VehColorValidate.php create mode 100644 app/common/model/VehColor.php diff --git a/app/admin/controller/BrandController.php b/app/admin/controller/BrandController.php index f917fa5..a265207 100644 --- a/app/admin/controller/BrandController.php +++ b/app/admin/controller/BrandController.php @@ -2,6 +2,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; +use app\common\service\OssService; use app\common\traits\crud\CrudControllerTrait; use app\admin\service\BrandService; @@ -28,6 +29,8 @@ class BrandController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (empty($data['logo'])) + $data['logo_full'] = (new OssService)->generatePrivateUrl($data['logo']); return $data; } @@ -43,6 +46,8 @@ class BrandController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (empty($data['logo'])) + $data['logo_full'] = (new OssService)->generatePrivateUrl($data['logo']); return $data; } } \ No newline at end of file diff --git a/app/admin/controller/VehColorController.php b/app/admin/controller/VehColorController.php new file mode 100644 index 0000000..0d208ae --- /dev/null +++ b/app/admin/controller/VehColorController.php @@ -0,0 +1,33 @@ +service = new VehColorService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/admin/logic/VehColorLogic.php b/app/admin/logic/VehColorLogic.php new file mode 100644 index 0000000..484ba21 --- /dev/null +++ b/app/admin/logic/VehColorLogic.php @@ -0,0 +1,17 @@ +validator; + } +} \ No newline at end of file diff --git a/app/admin/validate/VehColorValidate.php b/app/admin/validate/VehColorValidate.php new file mode 100644 index 0000000..1c619ec --- /dev/null +++ b/app/admin/validate/VehColorValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/VehColor.php b/app/common/model/VehColor.php new file mode 100644 index 0000000..9554aa5 --- /dev/null +++ b/app/common/model/VehColor.php @@ -0,0 +1,49 @@ + Date: Thu, 28 Aug 2025 11:18:53 +0800 Subject: [PATCH 06/20] =?UTF-8?q?=E5=93=81=E7=89=8Clogo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/BrandController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/controller/BrandController.php b/app/admin/controller/BrandController.php index a265207..f416d9d 100644 --- a/app/admin/controller/BrandController.php +++ b/app/admin/controller/BrandController.php @@ -29,7 +29,7 @@ class BrandController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - if (empty($data['logo'])) + if (!empty($data['logo'])) $data['logo_full'] = (new OssService)->generatePrivateUrl($data['logo']); return $data; } From 035450e7623585dfe48da1ede570399d410234ca Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 28 Aug 2025 14:04:58 +0800 Subject: [PATCH 07/20] =?UTF-8?q?=E6=94=B9=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/VehModificationController.php | 48 +++++++++++ app/admin/logic/VehModificationLogic.php | 17 ++++ app/admin/service/BrandSeriesService.php | 49 +++++++++++ app/admin/service/BrandService.php | 48 +++++++++++ app/admin/service/SysDictItemService.php | 7 ++ app/admin/service/SysDictService.php | 2 +- app/admin/service/VehModificationService.php | 83 +++++++++++++++++++ .../validate/VehModificationValidate.php | 29 +++++++ app/common/model/VehModification.php | 49 +++++++++++ config/route.php | 9 ++ 10 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 app/admin/controller/VehModificationController.php create mode 100644 app/admin/logic/VehModificationLogic.php create mode 100644 app/admin/service/VehModificationService.php create mode 100644 app/admin/validate/VehModificationValidate.php create mode 100644 app/common/model/VehModification.php diff --git a/app/admin/controller/VehModificationController.php b/app/admin/controller/VehModificationController.php new file mode 100644 index 0000000..fc057e1 --- /dev/null +++ b/app/admin/controller/VehModificationController.php @@ -0,0 +1,48 @@ +service = new VehModificationService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/logic/VehModificationLogic.php b/app/admin/logic/VehModificationLogic.php new file mode 100644 index 0000000..511a9f6 --- /dev/null +++ b/app/admin/logic/VehModificationLogic.php @@ -0,0 +1,17 @@ +validator; } + + /** + * 构建查询条件 + */ + + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + $config['where']['brand_id'] = $p['brand_id']; + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['series_code','series_name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + 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; + } } \ No newline at end of file diff --git a/app/admin/service/BrandService.php b/app/admin/service/BrandService.php index 83af709..c35df96 100644 --- a/app/admin/service/BrandService.php +++ b/app/admin/service/BrandService.php @@ -5,6 +5,7 @@ namespace app\admin\service; use app\admin\validate\BrandValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\Brand; +use support\Request; class BrandService { @@ -28,4 +29,51 @@ class BrandService { return new $this->validator; } + + /** + * 构建查询条件 + */ + + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['brand_code','brand_name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + 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; + } } \ No newline at end of file diff --git a/app/admin/service/SysDictItemService.php b/app/admin/service/SysDictItemService.php index e9269f4..577b9f0 100644 --- a/app/admin/service/SysDictItemService.php +++ b/app/admin/service/SysDictItemService.php @@ -51,6 +51,13 @@ class SysDictItemService if (isset($p['status']) && in_array($p['status'], [0,1])) { $config['where']['status'] = $p['status']; } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['item_label','item_value','remark'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } break; case 'show': $config['where']['id'] = $p['id']; diff --git a/app/admin/service/SysDictService.php b/app/admin/service/SysDictService.php index 82c6be6..1d08fcb 100644 --- a/app/admin/service/SysDictService.php +++ b/app/admin/service/SysDictService.php @@ -53,7 +53,7 @@ class SysDictService // 关键字 if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; - foreach (['dict_name','dict_code','description','whatsapp','contacts'] as $col) { + foreach (['dict_name','dict_code','description'] as $col) { $config['orWhere'][] = [$col, 'like', $k]; } } diff --git a/app/admin/service/VehModificationService.php b/app/admin/service/VehModificationService.php new file mode 100644 index 0000000..6c56d9b --- /dev/null +++ b/app/admin/service/VehModificationService.php @@ -0,0 +1,83 @@ +validator; + } + + /** + * 构建查询条件 + */ + + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 状态 + if (isset($p['type']) && $p['type']) { + $config['where']['type'] = $p['type']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['code','name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + 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; + } +} \ No newline at end of file diff --git a/app/admin/validate/VehModificationValidate.php b/app/admin/validate/VehModificationValidate.php new file mode 100644 index 0000000..805b049 --- /dev/null +++ b/app/admin/validate/VehModificationValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/VehModification.php b/app/common/model/VehModification.php new file mode 100644 index 0000000..d3bd16e --- /dev/null +++ b/app/common/model/VehModification.php @@ -0,0 +1,49 @@ + Date: Thu, 28 Aug 2025 15:19:39 +0800 Subject: [PATCH 08/20] =?UTF-8?q?=E8=B4=A6=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysAccountController.php | 48 +++++++++++ app/admin/logic/SysAccountLogic.php | 17 ++++ app/admin/service/SysAccountService.php | 82 +++++++++++++++++++ app/admin/validate/SysAccountValidate.php | 29 +++++++ app/common/controller/PresetController.php | 11 +++ app/common/logic/SysCurrencyLogic.php | 21 +++++ app/common/model/SysAccount.php | 49 +++++++++++ app/common/service/SysCurrencyService.php | 25 ++++++ config/route.php | 12 ++- 9 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 app/admin/controller/SysAccountController.php create mode 100644 app/admin/logic/SysAccountLogic.php create mode 100644 app/admin/service/SysAccountService.php create mode 100644 app/admin/validate/SysAccountValidate.php create mode 100644 app/common/logic/SysCurrencyLogic.php create mode 100644 app/common/model/SysAccount.php create mode 100644 app/common/service/SysCurrencyService.php diff --git a/app/admin/controller/SysAccountController.php b/app/admin/controller/SysAccountController.php new file mode 100644 index 0000000..dc90fd9 --- /dev/null +++ b/app/admin/controller/SysAccountController.php @@ -0,0 +1,48 @@ +service = new SysAccountService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/logic/SysAccountLogic.php b/app/admin/logic/SysAccountLogic.php new file mode 100644 index 0000000..104b060 --- /dev/null +++ b/app/admin/logic/SysAccountLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 状态 + if (isset($p['type']) && $p['type']) { + $config['where']['type'] = $p['type']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['account_name','account_number','bank_name','bank_branch','description'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + 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; + } +} \ No newline at end of file diff --git a/app/admin/validate/SysAccountValidate.php b/app/admin/validate/SysAccountValidate.php new file mode 100644 index 0000000..65cc1d7 --- /dev/null +++ b/app/admin/validate/SysAccountValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/controller/PresetController.php b/app/common/controller/PresetController.php index 37073c4..afc24cb 100644 --- a/app/common/controller/PresetController.php +++ b/app/common/controller/PresetController.php @@ -3,6 +3,7 @@ namespace app\common\controller; use app\admin\service\RoleService; +use app\common\service\SysCurrencyService; use support\Request; use app\common\service\CorpService; use app\common\service\CorpFeishuAppService; @@ -76,6 +77,16 @@ class PresetController extends BaseController } } + public function currency() + { + try { + $result = (new SysCurrencyService)->getList(); + return $this->success($result, '获取货币列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + public function cacheClear() { diff --git a/app/common/logic/SysCurrencyLogic.php b/app/common/logic/SysCurrencyLogic.php new file mode 100644 index 0000000..206efa2 --- /dev/null +++ b/app/common/logic/SysCurrencyLogic.php @@ -0,0 +1,21 @@ +get(['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent']); + } +} \ No newline at end of file diff --git a/app/common/model/SysAccount.php b/app/common/model/SysAccount.php new file mode 100644 index 0000000..def900f --- /dev/null +++ b/app/common/model/SysAccount.php @@ -0,0 +1,49 @@ +logic = (new SysCurrencyLogic()); + } + + /** + * 获取系统list + */ + public function getList() + { + return $this->logic->getList(); + } +} \ No newline at end of file diff --git a/config/route.php b/config/route.php index e5e6f27..3bd7266 100644 --- a/config/route.php +++ b/config/route.php @@ -61,6 +61,7 @@ Route::group('/common', function () { Route::any('/feishu/app', [app\common\controller\PresetController::class, 'feishuApp']); Route::any('/systems', [app\common\controller\PresetController::class, 'systems']); Route::any('/roles', [app\common\controller\PresetController::class, 'roles']); + Route::any('/currency', [app\common\controller\PresetController::class, 'currency']); Route::any('/cache/clear', [app\common\controller\PresetController::class, 'cacheClear']); Route::any('/menus', [app\common\controller\PresetController::class, 'menus']); }); @@ -235,7 +236,7 @@ Route::group('/admin', function () { Route::any('/destroy', [app\admin\controller\VehColorController::class, 'destroy']); }); - // 汽车颜色 + // 汽车改装项目 Route::group('/modification', function () { Route::any('/list', [app\admin\controller\VehModificationController::class, 'index']); Route::any('/show', [app\admin\controller\VehModificationController::class, 'show']); @@ -244,6 +245,15 @@ Route::group('/admin', function () { Route::any('/destroy', [app\admin\controller\VehModificationController::class, 'destroy']); }); + // 账户 + Route::group('/account', function () { + Route::any('/list', [app\admin\controller\SysAccountController::class, 'index']); + Route::any('/show', [app\admin\controller\SysAccountController::class, 'show']); + Route::any('/store', [app\admin\controller\SysAccountController::class, 'store']); + Route::any('/update', [app\admin\controller\SysAccountController::class, 'update']); + Route::any('/destroy', [app\admin\controller\SysAccountController::class, 'destroy']); + }); + }); From 87728793c22f44d9c7cdccfb9991a2c6fef6448a Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 28 Aug 2025 16:01:41 +0800 Subject: [PATCH 09/20] =?UTF-8?q?=E6=B8=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysAccountController.php | 4 + app/admin/controller/SysPortController.php | 53 +++++++++ app/admin/logic/SysPortLogic.php | 17 +++ app/admin/service/SysPortService.php | 103 ++++++++++++++++++ app/admin/validate/SysPortValidate.php | 29 +++++ app/common/model/SysPort.php | 49 +++++++++ config/route.php | 9 ++ 7 files changed, 264 insertions(+) create mode 100644 app/admin/controller/SysPortController.php create mode 100644 app/admin/logic/SysPortLogic.php create mode 100644 app/admin/service/SysPortService.php create mode 100644 app/admin/validate/SysPortValidate.php create mode 100644 app/common/model/SysPort.php diff --git a/app/admin/controller/SysAccountController.php b/app/admin/controller/SysAccountController.php index dc90fd9..64398bb 100644 --- a/app/admin/controller/SysAccountController.php +++ b/app/admin/controller/SysAccountController.php @@ -2,8 +2,10 @@ namespace app\admin\controller; use app\common\controller\BaseController; +use app\common\model\SysCurrency; use app\common\traits\crud\CrudControllerTrait; use app\admin\service\SysAccountService; +use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Currency; class SysAccountController extends BaseController { @@ -28,6 +30,7 @@ class SysAccountController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); return $data; } @@ -43,6 +46,7 @@ class SysAccountController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); return $data; } } \ No newline at end of file diff --git a/app/admin/controller/SysPortController.php b/app/admin/controller/SysPortController.php new file mode 100644 index 0000000..d98577e --- /dev/null +++ b/app/admin/controller/SysPortController.php @@ -0,0 +1,53 @@ +service = new SysPortService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + if (isset($data['country_id'])) + if (isset($data['country_id'])) + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr'); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + $data['country_name'] = Country::where('id', $data['country_id'])->value('cn_addr'); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/logic/SysPortLogic.php b/app/admin/logic/SysPortLogic.php new file mode 100644 index 0000000..434c24a --- /dev/null +++ b/app/admin/logic/SysPortLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** + * 构建查询条件 + */ + + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['port_code','port_name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + 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; + } + + /** + * 添加前置处理 + */ + public function beforeServiceStore($data, Request $request) + { + if(empty($data['lat'])) + unset($data['lat']); + if(empty($data['lng'])) + unset($data['lng']); + return $data; + } + + /** + * 添加前置处理 + */ + public function beforeServiceUpdate($data, Request $request) + { + if(empty($data['lat'])) + unset($data['lat']); + if(empty($data['lng'])) + unset($data['lng']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/validate/SysPortValidate.php b/app/admin/validate/SysPortValidate.php new file mode 100644 index 0000000..26cb9cd --- /dev/null +++ b/app/admin/validate/SysPortValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/SysPort.php b/app/common/model/SysPort.php new file mode 100644 index 0000000..2249b98 --- /dev/null +++ b/app/common/model/SysPort.php @@ -0,0 +1,49 @@ + Date: Fri, 29 Aug 2025 17:58:43 +0800 Subject: [PATCH 10/20] =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/PresetController.php | 91 +++++++++++++++++++ app/common/logic/BrandLogic.php | 22 +++++ app/common/logic/BrandSeriesLogic.php | 22 +++++ app/common/logic/SysAccountLogic.php | 22 +++++ app/common/logic/SysDictItemLogic.php | 22 +++++ app/common/logic/SysDictLogic.php | 27 ++++++ app/common/logic/SysPortLogic.php | 22 +++++ app/common/logic/VehColorLogic.php | 22 +++++ app/common/logic/VehModificationLogic.php | 22 +++++ app/common/service/BrandSeriesService.php | 34 +++++++ app/common/service/BrandService.php | 24 +++++ app/common/service/SysAccountService.php | 28 ++++++ app/common/service/SysDictItemService.php | 42 +++++++++ app/common/service/SysDictService.php | 28 ++++++ app/common/service/SysPortService.php | 28 ++++++ app/common/service/VehColorService.php | 33 +++++++ app/common/service/VehModificationService.php | 28 ++++++ config/route.php | 8 ++ 18 files changed, 525 insertions(+) create mode 100644 app/common/logic/BrandLogic.php create mode 100644 app/common/logic/BrandSeriesLogic.php create mode 100644 app/common/logic/SysAccountLogic.php create mode 100644 app/common/logic/SysDictItemLogic.php create mode 100644 app/common/logic/SysDictLogic.php create mode 100644 app/common/logic/SysPortLogic.php create mode 100644 app/common/logic/VehColorLogic.php create mode 100644 app/common/logic/VehModificationLogic.php create mode 100644 app/common/service/BrandSeriesService.php create mode 100644 app/common/service/BrandService.php create mode 100644 app/common/service/SysAccountService.php create mode 100644 app/common/service/SysDictItemService.php create mode 100644 app/common/service/SysDictService.php create mode 100644 app/common/service/SysPortService.php create mode 100644 app/common/service/VehColorService.php create mode 100644 app/common/service/VehModificationService.php diff --git a/app/common/controller/PresetController.php b/app/common/controller/PresetController.php index afc24cb..0d3ebf1 100644 --- a/app/common/controller/PresetController.php +++ b/app/common/controller/PresetController.php @@ -3,7 +3,15 @@ namespace app\common\controller; use app\admin\service\RoleService; +use app\common\service\BrandSeriesService; +use app\common\service\BrandService; +use app\common\service\SysAccountService; use app\common\service\SysCurrencyService; +use app\common\service\SysDictItemService; +use app\common\service\SysDictService; +use app\common\service\SysPortService; +use app\common\service\VehColorService; +use app\common\service\VehModificationService; use support\Request; use app\common\service\CorpService; use app\common\service\CorpFeishuAppService; @@ -87,6 +95,89 @@ class PresetController extends BaseController } } + public function brand() + { + try { + $result = (new BrandService)->getList(); + return $this->success($result, '获取品牌列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + public function series(Request $request) + { + try { + $params = $request->all(); + $result = (new BrandSeriesService)->getList($params); + return $this->success($result, '获取车系列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + public function account() + { + try { + $result = (new SysAccountService)->getList(); + return $this->success($result, '获取账号列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + public function dict() + { + try { + $result = (new SysDictService)->getList(); + return $this->success($result, '获取字典列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + public function dictItem(Request $request) + { + try { + $params = $request->all(); + $result = (new SysDictItemService)->getList($params); + return $this->success($result, '获取字典项列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + public function port() + { + try { + $result = (new SysPortService)->getList(); + return $this->success($result, '获取港口列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + public function color(Request $request) + { + try { + $params = $request->all(); + $result = (new VehColorService)->getList($params); + return $this->success($result, '获取颜色列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + public function modification() + { + try { + $result = (new VehModificationService)->getList(); + return $this->success($result, '获取货币列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + public function cacheClear() { diff --git a/app/common/logic/BrandLogic.php b/app/common/logic/BrandLogic.php new file mode 100644 index 0000000..3040572 --- /dev/null +++ b/app/common/logic/BrandLogic.php @@ -0,0 +1,22 @@ +orderBy('sort','desc')->get(['id', 'brand_code', 'brand_name', 'logo', 'description']); + } + +} \ No newline at end of file diff --git a/app/common/logic/BrandSeriesLogic.php b/app/common/logic/BrandSeriesLogic.php new file mode 100644 index 0000000..956ca55 --- /dev/null +++ b/app/common/logic/BrandSeriesLogic.php @@ -0,0 +1,22 @@ +where($where)->orderBy('sort','desc')->get(['id', 'series_code', 'series_name', 'description']); + } + +} \ No newline at end of file diff --git a/app/common/logic/SysAccountLogic.php b/app/common/logic/SysAccountLogic.php new file mode 100644 index 0000000..2f43410 --- /dev/null +++ b/app/common/logic/SysAccountLogic.php @@ -0,0 +1,22 @@ +orderBy('sort','desc')->get(['id', 'account_name', 'currency_id', 'account_number', 'bank_name', 'bank_branch', 'description']); + } + +} \ No newline at end of file diff --git a/app/common/logic/SysDictItemLogic.php b/app/common/logic/SysDictItemLogic.php new file mode 100644 index 0000000..d6efc72 --- /dev/null +++ b/app/common/logic/SysDictItemLogic.php @@ -0,0 +1,22 @@ +where($where)->orderBy('sort','desc')->get(['id', 'item_label', 'item_value', 'remark', 'dict_id']); + } + +} \ No newline at end of file diff --git a/app/common/logic/SysDictLogic.php b/app/common/logic/SysDictLogic.php new file mode 100644 index 0000000..6447ed3 --- /dev/null +++ b/app/common/logic/SysDictLogic.php @@ -0,0 +1,27 @@ +where('code', $code)->orderBy('sort','desc')->first(['id']); + } + + public function getList() + { + return SysDict::where('status', 1)->get(['id', 'dict_name', 'dict_code', 'description']); + } + +} \ No newline at end of file diff --git a/app/common/logic/SysPortLogic.php b/app/common/logic/SysPortLogic.php new file mode 100644 index 0000000..a2e78a8 --- /dev/null +++ b/app/common/logic/SysPortLogic.php @@ -0,0 +1,22 @@ +orderBy('sort','desc')->get(['id', 'port_code', 'port_name', 'country_id', 'description']); + } + +} \ No newline at end of file diff --git a/app/common/logic/VehColorLogic.php b/app/common/logic/VehColorLogic.php new file mode 100644 index 0000000..7a36811 --- /dev/null +++ b/app/common/logic/VehColorLogic.php @@ -0,0 +1,22 @@ +where($where)->orderBy('sort','desc')->get(['id', 'color_code', 'color_text']); + } + +} \ No newline at end of file diff --git a/app/common/logic/VehModificationLogic.php b/app/common/logic/VehModificationLogic.php new file mode 100644 index 0000000..3317235 --- /dev/null +++ b/app/common/logic/VehModificationLogic.php @@ -0,0 +1,22 @@ +orderBy('sort','desc')->get(['id', 'code', 'name', 'type', 'price']); + } + +} \ No newline at end of file diff --git a/app/common/service/BrandSeriesService.php b/app/common/service/BrandSeriesService.php new file mode 100644 index 0000000..ae91723 --- /dev/null +++ b/app/common/service/BrandSeriesService.php @@ -0,0 +1,34 @@ +logic = (new BrandSeriesLogic()); + } + + /** + * 获取系统list + */ + public function getList($params) + { + if (empty($params['brand_id'])) + throw new BusinessException('品牌id不能为空'); + $where = []; + if(isset($params['brand_id']) && $params['brand_id']) + $where[] = ['brand_id', '=', $params['brand_id']]; + return $this->logic->getList($where); + } +} \ No newline at end of file diff --git a/app/common/service/BrandService.php b/app/common/service/BrandService.php new file mode 100644 index 0000000..c3430fe --- /dev/null +++ b/app/common/service/BrandService.php @@ -0,0 +1,24 @@ +logic = (new BrandLogic()); + } + + /** + * 获取系统list + */ + public function getList() + { + return $this->logic->getList(); + } +} \ No newline at end of file diff --git a/app/common/service/SysAccountService.php b/app/common/service/SysAccountService.php new file mode 100644 index 0000000..b9c59ad --- /dev/null +++ b/app/common/service/SysAccountService.php @@ -0,0 +1,28 @@ +logic = (new SysAccountLogic()); + } + + /** + * 获取系统list + */ + public function getList() + { + return $this->logic->getList(); + } +} \ No newline at end of file diff --git a/app/common/service/SysDictItemService.php b/app/common/service/SysDictItemService.php new file mode 100644 index 0000000..c1e51ed --- /dev/null +++ b/app/common/service/SysDictItemService.php @@ -0,0 +1,42 @@ +logic = (new SysDictItemLogic()); + } + + /** + * 获取系统list + */ + public function getList($params) + { + if (empty($params['dict_id']) && empty($params['dict_code'])) + throw new BusinessException('未明确要查询的字典组'); + $where = []; + if(isset($params['dict_id']) && $params['dict_id']) + $where[] = ['dict_id', '=', $params['dict_id']]; + if(isset($params['dict_code']) && $params['dict_code']){ + $dict = (new SysDictLogic)->getDictByCode($params['dict_code']); + if (empty($dict['id'])) + throw new BusinessException('字典组code错误'); + $where[] = ['dict_id', '=', $dict['id']]; + } + + return $this->logic->getList($where); + } +} \ No newline at end of file diff --git a/app/common/service/SysDictService.php b/app/common/service/SysDictService.php new file mode 100644 index 0000000..57ab33c --- /dev/null +++ b/app/common/service/SysDictService.php @@ -0,0 +1,28 @@ +logic = (new SysDictLogic()); + } + + /** + * 获取系统list + */ + public function getList() + { + return $this->logic->getList(); + } +} \ No newline at end of file diff --git a/app/common/service/SysPortService.php b/app/common/service/SysPortService.php new file mode 100644 index 0000000..2918a96 --- /dev/null +++ b/app/common/service/SysPortService.php @@ -0,0 +1,28 @@ +logic = (new SysPortLogic()); + } + + /** + * 获取系统list + */ + public function getList() + { + return $this->logic->getList(); + } +} \ No newline at end of file diff --git a/app/common/service/VehColorService.php b/app/common/service/VehColorService.php new file mode 100644 index 0000000..2060efe --- /dev/null +++ b/app/common/service/VehColorService.php @@ -0,0 +1,33 @@ +logic = (new VehColorLogic()); + } + + /** + * 获取系统list + */ + public function getList($params) + { + if (empty($params['type'])) + throw new BusinessException('类型不能为空'); + $where = []; + if(isset($params['type']) && $params['type']) + $where[] = ['type', '=', $params['type']]; + return $this->logic->getList($where); + } +} \ No newline at end of file diff --git a/app/common/service/VehModificationService.php b/app/common/service/VehModificationService.php new file mode 100644 index 0000000..31c7119 --- /dev/null +++ b/app/common/service/VehModificationService.php @@ -0,0 +1,28 @@ +logic = (new VehModificationLogic()); + } + + /** + * 获取系统list + */ + public function getList() + { + return $this->logic->getList(); + } +} \ No newline at end of file diff --git a/config/route.php b/config/route.php index c5eba9a..c1fcfc1 100644 --- a/config/route.php +++ b/config/route.php @@ -64,6 +64,14 @@ Route::group('/common', function () { Route::any('/currency', [app\common\controller\PresetController::class, 'currency']); Route::any('/cache/clear', [app\common\controller\PresetController::class, 'cacheClear']); Route::any('/menus', [app\common\controller\PresetController::class, 'menus']); + Route::any('/brand', [app\common\controller\PresetController::class, 'brand']); + Route::any('/brand/series', [app\common\controller\PresetController::class, 'series']); + Route::any('/account', [app\common\controller\PresetController::class, 'account']); + Route::any('/dict', [app\common\controller\PresetController::class, 'dict']); + Route::any('/dictItem', [app\common\controller\PresetController::class, 'dictItem']); + Route::any('/port', [app\common\controller\PresetController::class, 'port']); + Route::any('/color', [app\common\controller\PresetController::class, 'color']); + Route::any('/modification', [app\common\controller\PresetController::class, 'modification']); }); From 935caa24f2ac553283513060333cd5ba96a19611 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 11:46:02 +0800 Subject: [PATCH 11/20] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SysDictCategoryController.php | 48 ++++++++++++++++++ app/admin/controller/VehColorController.php | 31 +++++++++--- app/admin/logic/SysDictCategoryLogic.php | 17 +++++++ app/admin/service/SysDictCategoryService.php | 31 ++++++++++++ .../validate/SysDictCategoryValidate.php | 29 +++++++++++ app/common/model/SysCurrency.php | 2 +- app/common/model/SysDictCategory.php | 49 +++++++++++++++++++ config/route.php | 9 ++++ 8 files changed, 207 insertions(+), 9 deletions(-) create mode 100644 app/admin/controller/SysDictCategoryController.php create mode 100644 app/admin/logic/SysDictCategoryLogic.php create mode 100644 app/admin/service/SysDictCategoryService.php create mode 100644 app/admin/validate/SysDictCategoryValidate.php create mode 100644 app/common/model/SysDictCategory.php diff --git a/app/admin/controller/SysDictCategoryController.php b/app/admin/controller/SysDictCategoryController.php new file mode 100644 index 0000000..a75980d --- /dev/null +++ b/app/admin/controller/SysDictCategoryController.php @@ -0,0 +1,48 @@ +service = new SysDictCategoryService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/controller/VehColorController.php b/app/admin/controller/VehColorController.php index 0d208ae..9f17c7c 100644 --- a/app/admin/controller/VehColorController.php +++ b/app/admin/controller/VehColorController.php @@ -22,12 +22,27 @@ class VehColorController extends BaseController * @param array $data * @return array */ - // protected function indexFormat($data) - // { - // if (isset($data['created_at'])) - // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); - // if (isset($data['updated_at'])) - // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - // return $data; - // } + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } } \ No newline at end of file diff --git a/app/admin/logic/SysDictCategoryLogic.php b/app/admin/logic/SysDictCategoryLogic.php new file mode 100644 index 0000000..c52cb72 --- /dev/null +++ b/app/admin/logic/SysDictCategoryLogic.php @@ -0,0 +1,17 @@ +validator; + } +} \ No newline at end of file diff --git a/app/admin/validate/SysDictCategoryValidate.php b/app/admin/validate/SysDictCategoryValidate.php new file mode 100644 index 0000000..f494854 --- /dev/null +++ b/app/admin/validate/SysDictCategoryValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/SysCurrency.php b/app/common/model/SysCurrency.php index 200a23b..a13d120 100644 --- a/app/common/model/SysCurrency.php +++ b/app/common/model/SysCurrency.php @@ -40,7 +40,7 @@ class SysCurrency extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'base_currency', 'float_percent', 'status', 'last_updated', 'created_at', 'updated_at']; + protected $fillable = ['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'base_currency', 'float_percent_up', 'float_percent_down', 'status', 'last_updated', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 diff --git a/app/common/model/SysDictCategory.php b/app/common/model/SysDictCategory.php new file mode 100644 index 0000000..fef0219 --- /dev/null +++ b/app/common/model/SysDictCategory.php @@ -0,0 +1,49 @@ + Date: Tue, 2 Sep 2025 13:54:21 +0800 Subject: [PATCH 12/20] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysDictCategoryController.php | 12 ++++++++++++ app/admin/logic/SysDictCategoryLogic.php | 4 ++++ app/admin/service/SysDictCategoryService.php | 9 +++++++++ config/route.php | 1 + 4 files changed, 26 insertions(+) diff --git a/app/admin/controller/SysDictCategoryController.php b/app/admin/controller/SysDictCategoryController.php index a75980d..c0c2593 100644 --- a/app/admin/controller/SysDictCategoryController.php +++ b/app/admin/controller/SysDictCategoryController.php @@ -4,6 +4,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; use app\common\traits\crud\CrudControllerTrait; use app\admin\service\SysDictCategoryService; +use support\Request; class SysDictCategoryController extends BaseController { @@ -45,4 +46,15 @@ class SysDictCategoryController extends BaseController $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); return $data; } + + public function preset(Request $request) + { + try { + $params = $request->all(); + $result = (new SysDictCategoryService)->getList($params); + return $this->success($result, '获取字典项列表'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/admin/logic/SysDictCategoryLogic.php b/app/admin/logic/SysDictCategoryLogic.php index c52cb72..6d8c413 100644 --- a/app/admin/logic/SysDictCategoryLogic.php +++ b/app/admin/logic/SysDictCategoryLogic.php @@ -14,4 +14,8 @@ class SysDictCategoryLogic */ protected string $modelClass = SysDictCategory::class; + public function getList() + { + return SysDictCategory::where('status', 1)->orderBy('sort','desc')->get(['id', 'category_name']); + } } \ No newline at end of file diff --git a/app/admin/service/SysDictCategoryService.php b/app/admin/service/SysDictCategoryService.php index 69ab18f..28e7be6 100644 --- a/app/admin/service/SysDictCategoryService.php +++ b/app/admin/service/SysDictCategoryService.php @@ -2,9 +2,11 @@ namespace app\admin\service; +use app\admin\logic\SysDictCategoryLogic; use app\admin\validate\SysDictCategoryValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\SysDictCategory; +use support\exception\BusinessException; class SysDictCategoryService { @@ -28,4 +30,11 @@ class SysDictCategoryService { return new $this->validator; } + /** + * 获取系统list + */ + public function getList($params) + { + return (new SysDictCategoryLogic)->getList(); + } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index 17458b7..cef6716 100644 --- a/config/route.php +++ b/config/route.php @@ -228,6 +228,7 @@ Route::group('/admin', function () { Route::any('/store', [app\admin\controller\SysDictCategoryController::class, 'store']); Route::any('/update', [app\admin\controller\SysDictCategoryController::class, 'update']); Route::any('/destroy', [app\admin\controller\SysDictCategoryController::class, 'destroy']); + Route::any('/preset', [app\admin\controller\SysDictCategoryController::class, 'preset']); }); }); From c1fb484e2402990b8faf25c0edfdc7c537605caf Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 13:59:48 +0800 Subject: [PATCH 13/20] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/SysDictService.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/admin/service/SysDictService.php b/app/admin/service/SysDictService.php index 1261c30..1ebf167 100644 --- a/app/admin/service/SysDictService.php +++ b/app/admin/service/SysDictService.php @@ -50,6 +50,10 @@ class SysDictService if (isset($p['status']) && in_array($p['status'], [0,1])) { $config['where']['status'] = $p['status']; } + // 分类筛选 + if (isset($p['category_id']) && !empty($p['category_id'])) { + $config['where']['category_id'] = $p['category_id']; + } // 关键字 if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; From aa5619f405136e065d877a22d928b5af15d1b7ff Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 14:47:21 +0800 Subject: [PATCH 14/20] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysDictController.php | 13 +++++++++++++ app/admin/service/SysDictService.php | 14 ++++++++++++++ config/route.php | 11 ++--------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/admin/controller/SysDictController.php b/app/admin/controller/SysDictController.php index 34be3e1..3ffef7e 100644 --- a/app/admin/controller/SysDictController.php +++ b/app/admin/controller/SysDictController.php @@ -75,4 +75,17 @@ class SysDictController extends BaseController return $this->error($e->getMessage()); } } + + public function group(Request $request) + { + try { + $raw = $this->service->group($request); + $data = $this->transformData($raw, method_exists($this, 'groupFormat') + ? [$this, 'groupFormat'] + : null); + return $this->success($data); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/admin/service/SysDictService.php b/app/admin/service/SysDictService.php index 1ebf167..6d1531d 100644 --- a/app/admin/service/SysDictService.php +++ b/app/admin/service/SysDictService.php @@ -87,11 +87,25 @@ class SysDictService $config['with']['sysDictItem'][] = 'item_label'; $config['with']['sysDictItem'][] = 'item_value'; break; + case 'group': + $config['order']['id'] = 'desc'; + $config['where']['id'] = 1; + $config['with']['sysDictItem'][] = 'dict_id'; + $config['with']['sysDictItem'][] = 'item_label'; + $config['with']['sysDictItem'][] = 'item_value'; + break; } return $config; } + public function group(Request $request) + { + $config = $this->buildQueryConfig($request, 'group'); + $result = $this->logicListAll($config); + return $this->postProcess('group', $result); + } + public function serviceListAllScope(Request $request) { diff --git a/config/route.php b/config/route.php index cef6716..2de1e13 100644 --- a/config/route.php +++ b/config/route.php @@ -212,6 +212,8 @@ Route::group('/admin', function () { Route::any('/update', [app\admin\controller\SysDictController::class, 'update']); Route::any('/destroy', [app\admin\controller\SysDictController::class, 'destroy']); Route::any('/scope', [app\admin\controller\SysDictController::class, 'listScope']); + // 字典分类 + Route::any('/group', [app\admin\controller\SysDictController::class, 'group']); Route::group('/item', function () { Route::any('/list', [app\admin\controller\SysDictItemController::class, 'index']); @@ -221,15 +223,6 @@ Route::group('/admin', function () { Route::any('/destroy', [app\admin\controller\SysDictItemController::class, 'destroy']); }); - // 分类 - Route::group('/category', function () { - Route::any('/list', [app\admin\controller\SysDictCategoryController::class, 'index']); - Route::any('/show', [app\admin\controller\SysDictCategoryController::class, 'show']); - Route::any('/store', [app\admin\controller\SysDictCategoryController::class, 'store']); - Route::any('/update', [app\admin\controller\SysDictCategoryController::class, 'update']); - Route::any('/destroy', [app\admin\controller\SysDictCategoryController::class, 'destroy']); - Route::any('/preset', [app\admin\controller\SysDictCategoryController::class, 'preset']); - }); }); // 货币 From 34f2284911cf9a61eaa82e394751070890eea226 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 14:59:11 +0800 Subject: [PATCH 15/20] =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/SysDictService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/service/SysDictService.php b/app/admin/service/SysDictService.php index 6d1531d..859628c 100644 --- a/app/admin/service/SysDictService.php +++ b/app/admin/service/SysDictService.php @@ -102,7 +102,7 @@ class SysDictService public function group(Request $request) { $config = $this->buildQueryConfig($request, 'group'); - $result = $this->logicListAll($config); + $result = $this->logicShow($config); return $this->postProcess('group', $result); } From 36f9c82c8bb55b028671be64a5481a05e7a49d3b Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 15:07:35 +0800 Subject: [PATCH 16/20] =?UTF-8?q?=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysDictController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/admin/controller/SysDictController.php b/app/admin/controller/SysDictController.php index 3ffef7e..b8a8c13 100644 --- a/app/admin/controller/SysDictController.php +++ b/app/admin/controller/SysDictController.php @@ -32,6 +32,7 @@ class SysDictController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + $data['category'] = SysDictItem::where('id',$data['category_id'])->value('item_label'); return $data; } From 4ad408c0b2d2b4dbf7349e4a381bffbed7ec8736 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 15:42:30 +0800 Subject: [PATCH 17/20] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E4=B8=8B=E6=8B=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysDictController.php | 7 +++-- app/common/model/SysDict.php | 2 +- app/crm/controller/CustomerController.php | 19 +++++++++++++ app/crm/service/CustomerService.php | 33 ++++++++++++++++++++++ config/route.php | 1 + 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/app/admin/controller/SysDictController.php b/app/admin/controller/SysDictController.php index b8a8c13..b75f923 100644 --- a/app/admin/controller/SysDictController.php +++ b/app/admin/controller/SysDictController.php @@ -32,8 +32,11 @@ class SysDictController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - $data['category'] = SysDictItem::where('id',$data['category_id'])->value('item_label'); - + if (isset($data['category_id'])){ + $data['category'] = SysDictItem::where('id',$data['category_id'])->value('item_label'); + } else { + $data['category'] = ''; + } return $data; } diff --git a/app/common/model/SysDict.php b/app/common/model/SysDict.php index 7ef5a62..ad7cf5c 100644 --- a/app/common/model/SysDict.php +++ b/app/common/model/SysDict.php @@ -43,7 +43,7 @@ class SysDict extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'dict_name', 'dict_code', 'description', 'status', 'created_at', 'updated_at', 'deleted_at']; + protected $fillable = ['id', 'category_id', 'dict_name', 'dict_code', 'description', 'status', 'created_at', 'updated_at', 'deleted_at']; /** * 不允许自动填充模型字段 diff --git a/app/crm/controller/CustomerController.php b/app/crm/controller/CustomerController.php index 0860af8..b2e125e 100644 --- a/app/crm/controller/CustomerController.php +++ b/app/crm/controller/CustomerController.php @@ -205,6 +205,25 @@ class CustomerController extends BaseController } } + /** + * 客户下拉 + * @param Request $request + * @return \support\Response + */ + public function preset(Request $request) + { + try { + $param = $request->all(); + $param['user_id'] = $request->user->uid; + $param['corp_abbr'] = $request->basic_data['corp_abbr']; + $result = (new CustomerService())->preset($param); + + return $this->success($result); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + /** * 客户恢复 * @param Request $request diff --git a/app/crm/service/CustomerService.php b/app/crm/service/CustomerService.php index c20ceab..c08b21d 100644 --- a/app/crm/service/CustomerService.php +++ b/app/crm/service/CustomerService.php @@ -164,6 +164,39 @@ class CustomerService return $customer; } + public function preset($params) + { + $keyword = $params['keyword'] ?? ''; + $where = []; + $user_id =$params['user_id']; + + $where[] = ['status', 1]; + $where[] = ['user_id', $user_id]; + + if (!empty($countryId)){ + $where[] = ['country_id', $countryId]; + } + + $query = Customer::select('id','code','sn','corp_id','email','phone','WhatsApp','contacts','company')->where($where); + + if (!Util::isEmpty($keyword)) { + $query->where(function ($query) use ($keyword) { + $query->where('contacts', 'like', "%{$keyword}%") + ->orWhere('phone', 'like', "%{$keyword}%") + ->orWhere('email', 'like', "%{$keyword}%") + ->orWhere('WhatsApp', 'like', "%{$keyword}%") + ->orWhere('code', 'like', "%{$keyword}%"); + }); + } + $customer = $query->orderBy('follow_last','desc')->get(); + + foreach ($customer as &$item) { + } + unset($item); + + return $customer; + } + /** 分页列表 */ public function serviceList(Request $request) diff --git a/config/route.php b/config/route.php index 2de1e13..5bab335 100644 --- a/config/route.php +++ b/config/route.php @@ -340,6 +340,7 @@ Route::group('/crm', function () { Route::any('/customer/followNext', [app\crm\controller\CustomerController::class, 'followNext']); Route::any('/customer/report', [app\crm\controller\CustomerController::class, 'report']); Route::any('/customer/distinctNotice', [app\crm\controller\CustomerController::class, 'distinctNotice']); + Route::any('/customer/preset', [app\crm\controller\CustomerController::class, 'preset']); Route::any('/tagGroup/list', [app\crm\controller\TagGroupController::class, 'list']); Route::any('/tagGroup/updatePivot', [app\crm\controller\TagGroupController::class, 'updatePivot']); From 005bc4e2e6b8ba6afe637f0e09452ab9e8d3d8fe Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 17:02:03 +0800 Subject: [PATCH 18/20] =?UTF-8?q?=E8=B4=A7=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysAccountController.php | 6 ++++-- app/common/model/SysAccount.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/admin/controller/SysAccountController.php b/app/admin/controller/SysAccountController.php index 64398bb..aa4b132 100644 --- a/app/admin/controller/SysAccountController.php +++ b/app/admin/controller/SysAccountController.php @@ -30,7 +30,8 @@ class SysAccountController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); + if (isset($data['currency_name'])) + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); return $data; } @@ -46,7 +47,8 @@ class SysAccountController extends BaseController $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); if (isset($data['updated_at'])) $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); - $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); + if (isset($data['currency_name'])) + $data['currency_name'] = SysCurrency::where('id', $data['currency_id'])->value('currency_name'); return $data; } } \ No newline at end of file diff --git a/app/common/model/SysAccount.php b/app/common/model/SysAccount.php index def900f..693e823 100644 --- a/app/common/model/SysAccount.php +++ b/app/common/model/SysAccount.php @@ -40,7 +40,7 @@ class SysAccount extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'account_name', 'account_type', 'account_number', 'account_holder', 'bank_name', 'bank_branch', 'daily_limit', 'single_limit', 'description', 'status', 'sort', 'created_at', 'updated_at']; + protected $fillable = ['id', 'currency_id', 'account_name', 'account_number', 'account_holder', 'bank_name', 'bank_branch', 'daily_limit', 'single_limit', 'description', 'status', 'sort', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 From a3d39feace32377335f797fc729cb01d4b133a45 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 17:14:11 +0800 Subject: [PATCH 19/20] =?UTF-8?q?=E8=B4=A7=E5=B8=81=E4=B8=8B=E6=8B=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/SysCurrencyLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/SysCurrencyLogic.php b/app/common/logic/SysCurrencyLogic.php index 206efa2..b1faedc 100644 --- a/app/common/logic/SysCurrencyLogic.php +++ b/app/common/logic/SysCurrencyLogic.php @@ -16,6 +16,6 @@ class SysCurrencyLogic public function getList() { - return SysCurrency::where('status', 1)->get(['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent']); + return SysCurrency::where('status', 1)->get(['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent_up', 'float_percent_down']); } } \ No newline at end of file From 152ce9a75f050d731217c9225a18f6cf57eee5a4 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 2 Sep 2025 18:04:09 +0800 Subject: [PATCH 20/20] =?UTF-8?q?=E6=B8=AF=E5=8F=A3=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/SysCurrencyController.php | 11 +++++++++++ app/admin/service/SysPortService.php | 8 ++++++++ app/common/controller/PresetController.php | 5 +++-- app/common/logic/SysCurrencyLogic.php | 2 +- app/common/logic/SysPortLogic.php | 4 ++-- app/common/model/SysCurrency.php | 2 +- app/common/service/SysPortService.php | 12 ++++++++++-- 7 files changed, 36 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/SysCurrencyController.php b/app/admin/controller/SysCurrencyController.php index 0e96169..db9d589 100644 --- a/app/admin/controller/SysCurrencyController.php +++ b/app/admin/controller/SysCurrencyController.php @@ -2,6 +2,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; +use app\common\model\Country; use app\common\traits\crud\CrudControllerTrait; use app\admin\service\SysCurrencyService; @@ -30,6 +31,11 @@ class SysCurrencyController extends BaseController $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); if (isset($data['last_updated'])) $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + if (isset($data['country_id'])){ + $data['country_name'] = Country::where('id',$data['country_id'])->value('item_label'); + } else { + $data['country_name'] = ''; + } return $data; } @@ -47,6 +53,11 @@ class SysCurrencyController extends BaseController $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); if (isset($data['last_updated'])) $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + if (isset($data['country_id'])){ + $data['country_name'] = Country::where('id',$data['country_id'])->value('item_label'); + } else { + $data['country_name'] = ''; + } return $data; } } \ No newline at end of file diff --git a/app/admin/service/SysPortService.php b/app/admin/service/SysPortService.php index 7a2dfd0..6e8774c 100644 --- a/app/admin/service/SysPortService.php +++ b/app/admin/service/SysPortService.php @@ -58,6 +58,14 @@ class SysPortService $config['orWhere'][] = [$col, 'like', $k]; } } + // 场景 + if (isset($p['scene']) && $p['scene']) { + if($p['country_id'] == 'domestic'){ + $config['where']['country_id'] = 45; + }else{ + $config['where']['country_id'] = ['<>', 45]; + } + } //$config['where']['status'] = 1; break; case 'show': diff --git a/app/common/controller/PresetController.php b/app/common/controller/PresetController.php index 0d3ebf1..1abe3de 100644 --- a/app/common/controller/PresetController.php +++ b/app/common/controller/PresetController.php @@ -147,10 +147,11 @@ class PresetController extends BaseController } } - public function port() + public function port(Request $request) { try { - $result = (new SysPortService)->getList(); + $params = $request->all(); + $result = (new SysPortService)->getList($params); return $this->success($result, '获取港口列表'); } catch (\Throwable $e) { return $this->error($e->getMessage()); diff --git a/app/common/logic/SysCurrencyLogic.php b/app/common/logic/SysCurrencyLogic.php index b1faedc..4de7559 100644 --- a/app/common/logic/SysCurrencyLogic.php +++ b/app/common/logic/SysCurrencyLogic.php @@ -16,6 +16,6 @@ class SysCurrencyLogic public function getList() { - return SysCurrency::where('status', 1)->get(['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent_up', 'float_percent_down']); + return SysCurrency::where('status', 1)->get(['id', 'country_id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent_up', 'float_percent_down']); } } \ No newline at end of file diff --git a/app/common/logic/SysPortLogic.php b/app/common/logic/SysPortLogic.php index a2e78a8..e12c260 100644 --- a/app/common/logic/SysPortLogic.php +++ b/app/common/logic/SysPortLogic.php @@ -14,9 +14,9 @@ class SysPortLogic */ protected string $modelClass = SysPort::class; - public function getList() + public function getList($where) { - return SysPort::where('status', 1)->orderBy('sort','desc')->get(['id', 'port_code', 'port_name', 'country_id', 'description']); + return SysPort::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'port_code', 'port_name', 'country_id', 'description']); } } \ No newline at end of file diff --git a/app/common/model/SysCurrency.php b/app/common/model/SysCurrency.php index a13d120..57b4339 100644 --- a/app/common/model/SysCurrency.php +++ b/app/common/model/SysCurrency.php @@ -40,7 +40,7 @@ class SysCurrency extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'base_currency', 'float_percent_up', 'float_percent_down', 'status', 'last_updated', 'created_at', 'updated_at']; + protected $fillable = ['id', 'country_id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'base_currency', 'float_percent_up', 'float_percent_down', 'status', 'last_updated', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 diff --git a/app/common/service/SysPortService.php b/app/common/service/SysPortService.php index 2918a96..a4ed6cd 100644 --- a/app/common/service/SysPortService.php +++ b/app/common/service/SysPortService.php @@ -21,8 +21,16 @@ class SysPortService /** * 获取系统list */ - public function getList() + public function getList($params) { - return $this->logic->getList(); + $where = []; + if(isset($params['scene']) && $params['scene']) { + if($params['scene'] == 'domestic'){ + $where['country_id'] = 45; + }else{ + $where['country_id'] = ['<>', 45]; + } + } + return $this->logic->getList($where); } } \ No newline at end of file