diff --git a/app/admin/controller/SysDictController.php b/app/admin/controller/SysDictController.php index 0e0b8d7..34be3e1 100644 --- a/app/admin/controller/SysDictController.php +++ b/app/admin/controller/SysDictController.php @@ -51,4 +51,28 @@ class SysDictController extends BaseController $data['sysDictItem'] = SysDictItem::where('dict_id',$data['id'])->get(); return $data; } + + + + public function listScopeFormat($data) + { + $rdata = []; + foreach ($data as $item) { + $rdata[$item['dict_code']] = $item['sysDictItem']; + } + return $rdata; + } + + public function listScope(Request $request) + { + try { + $raw = $this->service->serviceListAllScope($request); + $data = $this->transformData($raw, method_exists($this, 'listScopeFormat') + ? [$this, 'listScopeFormat'] + : 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 1d08fcb..1261c30 100644 --- a/app/admin/service/SysDictService.php +++ b/app/admin/service/SysDictService.php @@ -74,8 +74,36 @@ class SysDictService break; case 'store': break; + case 'scope': + $config['order']['id'] = 'desc'; + if (isset($p['scope']) && !empty($p['scope'])) { + $config['where']['id'] = ['in', explode(',', $p['scope'])]; + } + $config['with']['sysDictItem'][] = 'dict_id'; + $config['with']['sysDictItem'][] = 'item_label'; + $config['with']['sysDictItem'][] = 'item_value'; + break; } return $config; } + + + public function serviceListAllScope(Request $request) + { + $config = $this->buildQueryConfig($request, 'scope'); + $result = $this->logicListAll($config); + return $this->postProcess('ListAllScope', $result); + } + + + public function afterServiceListAllScope($data) + { + + // $data->each(function (&$item) { + + // }); + + return $data; + } } \ No newline at end of file diff --git a/app/common/controller/VehVehicleSkuController.php b/app/common/controller/VehVehicleSkuController.php index 3ab3eb5..3272f28 100644 --- a/app/common/controller/VehVehicleSkuController.php +++ b/app/common/controller/VehVehicleSkuController.php @@ -90,7 +90,7 @@ class VehVehicleSkuController extends BaseController } - public function index22(Request $request) + public function fields_desc(Request $request) { $data = [ 'sku_code' , // 'SKU编码,系统生成', diff --git a/app/queue/redis/InquiryToCrmNew_BACKUP_5243.php b/app/queue/redis/InquiryToCrmNew_BACKUP_5243.php deleted file mode 100644 index d63b683..0000000 --- a/app/queue/redis/InquiryToCrmNew_BACKUP_5243.php +++ /dev/null @@ -1,218 +0,0 @@ -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 deleted file mode 100644 index e69de29..0000000 diff --git a/app/queue/redis/InquiryToCrmNew_LOCAL_5243.php b/app/queue/redis/InquiryToCrmNew_LOCAL_5243.php deleted file mode 100644 index a350c7e..0000000 --- a/app/queue/redis/InquiryToCrmNew_LOCAL_5243.php +++ /dev/null @@ -1,204 +0,0 @@ -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 deleted file mode 100644 index 075deda..0000000 --- a/app/queue/redis/InquiryToCrmNew_REMOTE_5243.php +++ /dev/null @@ -1,207 +0,0 @@ -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 e5c77fc..38c7907 100644 --- a/config/route.php +++ b/config/route.php @@ -211,6 +211,7 @@ Route::group('/admin', function () { 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::any('/scope', [app\admin\controller\SysDictController::class, 'listScope']); Route::group('/item', function () { Route::any('/list', [app\admin\controller\SysDictItemController::class, 'index']);