get("type","base"); $data = $this->model->where("type",$type)->where("agent_id",$request->user['agent_id'])->findOrEmpty(); $result = []; if (!$data->isEmpty()) { $result = $data['content']; } if ($type == 'life') { $result['webhook'] = "https://notify.jsshuita.com/dy/hook/".$request->user['agent_id']; $result['spi'] = "https://notify.jsshuita.com/dy/spi/".$request->user['agent_id']; } if ($type == 'meituan') { $result['webhook'] = "https://notify.jsshuita.com/mt/hook/".$request->user['agent_id']; } $result['auth'] = (new SaasAgent)->where("agent_id",$request->user['agent_id'])->value('mall_type'); return successTrans("success.data",$result,empty($result)?2:1); } catch (\Throwable $exception) { return error($exception->getMessage()); } } /** * 保存通用配置 * @param Request $request * @return Response */ #[Route(path: "save",methods: "post")] public function setConfigData(Request $request): Response { try { $param = $request->post(); $resp = $this->model->where("agent_id",$request->user['user_id'])->where("type",$param['type'])->findOrEmpty(); if ($resp->isEmpty()) { $state = $resp->insert([ "agent_id" => $request->user['user_id'], "type" => $param['type'], "content" => json_encode($param['data']) ]); } else { $state = $resp->save([ "content" => json_encode($param['data']) ]); } if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $exception){ return error($exception->getMessage()); } } }