|
@@ -33,6 +33,7 @@ use Hyperf\Paginator\Paginator;
|
|
use App\Model\User;
|
|
use App\Model\User;
|
|
use Fukuball\Jieba\Jieba;
|
|
use Fukuball\Jieba\Jieba;
|
|
use Fukuball\Jieba\Finalseg;
|
|
use Fukuball\Jieba\Finalseg;
|
|
|
|
+
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
{
|
|
{
|
|
@@ -473,7 +474,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
}
|
|
}
|
|
public function getZhinengbumen(array $data): array
|
|
public function getZhinengbumen(array $data): array
|
|
{
|
|
{
|
|
- $result = Department::where('id', $data['id'])->first();
|
|
|
|
|
|
+ $result = Department::where('id', $data['id'])
|
|
|
|
+ ->orderBy('department', 'desc')
|
|
|
|
+ ->first();
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
public function getPidZhinengbumen(array $data): array
|
|
public function getPidZhinengbumen(array $data): array
|
|
@@ -665,12 +668,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
if (isset($data['name']) && $data['name']) {
|
|
if (isset($data['name']) && $data['name']) {
|
|
array_push($where, ['template_class.name', 'like', '%' . $data['name'] . '%']);
|
|
array_push($where, ['template_class.name', 'like', '%' . $data['name'] . '%']);
|
|
}
|
|
}
|
|
- if(isset($data['keyword']) && $data['keyword']){
|
|
|
|
- array_push($where, ['template_class.keyword', 'like', '%'. $data['keyword']. '%']);
|
|
|
|
|
|
+ if (isset($data['keyword']) && $data['keyword']) {
|
|
|
|
+ array_push($where, ['template_class.keyword', 'like', '%' . $data['keyword'] . '%']);
|
|
}
|
|
}
|
|
$template = TemplateClass::when($where, function ($query) use ($where) {
|
|
$template = TemplateClass::when($where, function ($query) use ($where) {
|
|
- $query->where($where);
|
|
|
|
- });
|
|
|
|
|
|
+ $query->where($where);
|
|
|
|
+ });
|
|
$count = $template->count();
|
|
$count = $template->count();
|
|
// $countQuery = clone $template;
|
|
// $countQuery = clone $template;
|
|
$row = $template
|
|
$row = $template
|
|
@@ -730,10 +733,10 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
if (empty($template_class)) {
|
|
if (empty($template_class)) {
|
|
return Result::error("未查询到风格", 0);
|
|
return Result::error("未查询到风格", 0);
|
|
}
|
|
}
|
|
- if($template_class->type == 1){
|
|
|
|
|
|
+ if ($template_class->type == 1) {
|
|
return Result::error("默认风格不能修改", 0);
|
|
return Result::error("默认风格不能修改", 0);
|
|
}
|
|
}
|
|
- $template = TemplateClass::where('id','!=',$data['id'])
|
|
|
|
|
|
+ $template = TemplateClass::where('id', '!=', $data['id'])
|
|
// ->where(['name' => $data['name']])
|
|
// ->where(['name' => $data['name']])
|
|
// ->orWhere(['class_id' => $data['class_id']])
|
|
// ->orWhere(['class_id' => $data['class_id']])
|
|
->where(function ($query) use ($data) {
|
|
->where(function ($query) use ($data) {
|
|
@@ -771,7 +774,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
if (empty($template)) {
|
|
if (empty($template)) {
|
|
return Result::error("未查询到风格", 0);
|
|
return Result::error("未查询到风格", 0);
|
|
}
|
|
}
|
|
- if($template->type == 1){
|
|
|
|
|
|
+ if ($template->type == 1) {
|
|
return Result::error("默认风格不能删除", 0);
|
|
return Result::error("默认风格不能删除", 0);
|
|
}
|
|
}
|
|
$result = TemplateClass::where($where)->delete();
|
|
$result = TemplateClass::where($where)->delete();
|
|
@@ -803,17 +806,17 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
$where['template_class_id'] = $data['template_class_id'];
|
|
$where['template_class_id'] = $data['template_class_id'];
|
|
}
|
|
}
|
|
if (!empty($data['template_name'])) {
|
|
if (!empty($data['template_name'])) {
|
|
- array_push($where, ['template_name', 'like', '%'. $data['template_name']. '%']);
|
|
|
|
|
|
+ array_push($where, ['template_name', 'like', '%' . $data['template_name'] . '%']);
|
|
}
|
|
}
|
|
if (!empty($data['template_keyword'])) {
|
|
if (!empty($data['template_keyword'])) {
|
|
- array_push($where, ['template_keyword', 'like', '%'. $data['template_keyword']. '%']);
|
|
|
|
|
|
+ array_push($where, ['template_keyword', 'like', '%' . $data['template_keyword'] . '%']);
|
|
}
|
|
}
|
|
$result = Template::where($where)
|
|
$result = Template::where($where)
|
|
->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
|
|
->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
|
|
->select('template.*', 'template_class.name as template_class_name')
|
|
->select('template.*', 'template_class.name as template_class_name')
|
|
->orderBy('template.id', 'desc')
|
|
->orderBy('template.id', 'desc')
|
|
->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
return Result::error("暂无皮肤", 0);
|
|
return Result::error("暂无皮肤", 0);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
@@ -824,7 +827,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
|
|
->leftJoin('template_class', 'template.template_class_id', 'template_class.id')
|
|
->select('template.*', 'template_class.name as template_class_name')
|
|
->select('template.*', 'template_class.name as template_class_name')
|
|
->first();
|
|
->first();
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
return Result::error("暂无皮肤", 0);
|
|
return Result::error("暂无皮肤", 0);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
@@ -848,9 +851,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
$page_type = json_decode($data['page_type'], true);
|
|
$page_type = json_decode($data['page_type'], true);
|
|
$data['page_type'] = json_encode(array_values(array_unique($page_type)));
|
|
$data['page_type'] = json_encode(array_values(array_unique($page_type)));
|
|
$result = Template::insertGetId($data);
|
|
$result = Template::insertGetId($data);
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
return Result::error("创建失败", 0);
|
|
return Result::error("创建失败", 0);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -945,11 +948,11 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
* 获取经纬度信息
|
|
* 获取经纬度信息
|
|
* @return void
|
|
* @return void
|
|
*/
|
|
*/
|
|
- public function getIpInfo(array $data) :array
|
|
|
|
|
|
+ public function getIpInfo(array $data): array
|
|
{
|
|
{
|
|
- $client_ip = isset($data['ip']) && $data['ip']??$_SERVER['REMOTE_ADDR'];
|
|
|
|
|
|
+ $client_ip = isset($data['ip']) && $data['ip'] ?? $_SERVER['REMOTE_ADDR'];
|
|
// 使用 IPinfo 服务获取 IP 信息
|
|
// 使用 IPinfo 服务获取 IP 信息
|
|
-// $api_url = "https://ipinfo.io/{$client_ip}/json";
|
|
|
|
|
|
+ // $api_url = "https://ipinfo.io/{$client_ip}/json";
|
|
//http://ip-api.com/json/117.136.12.79?lang=zh-cn
|
|
//http://ip-api.com/json/117.136.12.79?lang=zh-cn
|
|
$api_url = "http://ip-api.com/json/{$client_ip}/?lang=zh-cn";
|
|
$api_url = "http://ip-api.com/json/{$client_ip}/?lang=zh-cn";
|
|
$ch = curl_init($api_url);
|
|
$ch = curl_init($api_url);
|
|
@@ -960,14 +963,14 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
$ip_info = json_decode($response, true);
|
|
$ip_info = json_decode($response, true);
|
|
// 提取地址和经纬度
|
|
// 提取地址和经纬度
|
|
if ($ip_info) {
|
|
if ($ip_info) {
|
|
-// $latitude = explode(',', $ip_info['loc'])[0];
|
|
|
|
-// $longitude = explode(',', $ip_info['loc'])[1];
|
|
|
|
|
|
+ // $latitude = explode(',', $ip_info['loc'])[0];
|
|
|
|
+ // $longitude = explode(',', $ip_info['loc'])[1];
|
|
$ip_info['latitude'] = $ip_info['lat'];
|
|
$ip_info['latitude'] = $ip_info['lat'];
|
|
$ip_info['longitude'] = $ip_info['lon'];
|
|
$ip_info['longitude'] = $ip_info['lon'];
|
|
return Result::success($ip_info);
|
|
return Result::success($ip_info);
|
|
} else {
|
|
} else {
|
|
$data['ip'] = '101.254.114.212';
|
|
$data['ip'] = '101.254.114.212';
|
|
- $this->getIpinfo(["ip"=>$data['ip']]);
|
|
|
|
|
|
+ $this->getIpinfo(["ip" => $data['ip']]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -976,7 +979,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
* @param array $data
|
|
* @param array $data
|
|
* @return array
|
|
* @return array
|
|
*/
|
|
*/
|
|
- public function getWeatherInfo(array $data) :array
|
|
|
|
|
|
+ public function getWeatherInfo(array $data): array
|
|
{
|
|
{
|
|
$month = $data['month'] ?? date('m');
|
|
$month = $data['month'] ?? date('m');
|
|
$day = $data['day'] ?? date('d');
|
|
$day = $data['day'] ?? date('d');
|
|
@@ -989,8 +992,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
if ($cachedData = $cache->get($cacheKey)) {
|
|
if ($cachedData = $cache->get($cacheKey)) {
|
|
return Result::success(unserialize($cachedData));
|
|
return Result::success(unserialize($cachedData));
|
|
}
|
|
}
|
|
- $location = $data['latitude'].":".$data['longitude'];
|
|
|
|
- $api_url = "https://api.seniverse.com/v3/weather/now.json?key=".\Hyperf\Support\env('WEATHER_KEY')."&location=".$location."&language=zh-Hans&unit=c";
|
|
|
|
|
|
+ $location = $data['latitude'] . ":" . $data['longitude'];
|
|
|
|
+ $api_url = "https://api.seniverse.com/v3/weather/now.json?key=" . \Hyperf\Support\env('WEATHER_KEY') . "&location=" . $location . "&language=zh-Hans&unit=c";
|
|
$ch = curl_init($api_url);
|
|
$ch = curl_init($api_url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$response = curl_exec($ch);
|
|
$response = curl_exec($ch);
|
|
@@ -999,9 +1002,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
$WeatherInfo = json_decode($response, true);
|
|
$WeatherInfo = json_decode($response, true);
|
|
// 缓存结果,设置1小时过期
|
|
// 缓存结果,设置1小时过期
|
|
$cache->set($cacheKey, serialize($WeatherInfo), 3600);
|
|
$cache->set($cacheKey, serialize($WeatherInfo), 3600);
|
|
- if($WeatherInfo){
|
|
|
|
|
|
+ if ($WeatherInfo) {
|
|
return Result::success($WeatherInfo);
|
|
return Result::success($WeatherInfo);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return Result::error("获取天气失败", 0);
|
|
return Result::error("获取天气失败", 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1010,7 +1013,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
* 获取农历信息
|
|
* 获取农历信息
|
|
* @return void
|
|
* @return void
|
|
*/
|
|
*/
|
|
- public function getCalendar(array $data) :array
|
|
|
|
|
|
+ public function getCalendar(array $data): array
|
|
{
|
|
{
|
|
$calendar = new Calendar();
|
|
$calendar = new Calendar();
|
|
$result = $calendar->solar($data['year'], $data['month'], $data['day'], $data['hour']); // 阳历
|
|
$result = $calendar->solar($data['year'], $data['month'], $data['day'], $data['hour']); // 阳历
|
|
@@ -1099,7 +1102,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
$result = Component::where('id', $data['id'])->update($data);
|
|
$result = Component::where('id', $data['id'])->update($data);
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function getWebsiteTemplateInfo(array $data)
|
|
public function getWebsiteTemplateInfo(array $data)
|
|
{
|
|
{
|
|
$where = [];
|
|
$where = [];
|
|
@@ -1125,12 +1128,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
public function getWebPageType(array $data): array
|
|
public function getWebPageType(array $data): array
|
|
{
|
|
{
|
|
// 1:图片 2:文字 3:底部
|
|
// 1:图片 2:文字 3:底部
|
|
- $friend_link = Link::where('website_id', $data['website_id'])->where('type',3)->get();
|
|
|
|
- if(empty($friend_link->toArray())){
|
|
|
|
|
|
+ $friend_link = Link::where('website_id', $data['website_id'])->where('type', 3)->get();
|
|
|
|
+ if (empty($friend_link->toArray())) {
|
|
return Result::error('暂无友情链接数据!');
|
|
return Result::error('暂无友情链接数据!');
|
|
}
|
|
}
|
|
$footer_category = FooterCategory::where('website_id', $data['website_id'])->get();
|
|
$footer_category = FooterCategory::where('website_id', $data['website_id'])->get();
|
|
- if(empty($footer_category->toArray())){
|
|
|
|
|
|
+ if (empty($footer_category->toArray())) {
|
|
return Result::error('暂无底部导航数据!');
|
|
return Result::error('暂无底部导航数据!');
|
|
}
|
|
}
|
|
$result = [
|
|
$result = [
|
|
@@ -1147,13 +1150,13 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
public function addWebPageType(array $data): array
|
|
public function addWebPageType(array $data): array
|
|
{
|
|
{
|
|
// 1:首页 2:频道页 3:列表页 4:详情页 5:搜索页 6:特殊列表 7:特殊详情页'
|
|
// 1:首页 2:频道页 3:列表页 4:详情页 5:搜索页 6:特殊列表 7:特殊详情页'
|
|
- if($data['is_search'] == 1){
|
|
|
|
- $page_type = json_encode([1,2,3,4,5,6,7]);
|
|
|
|
- }else{
|
|
|
|
- $page_type = json_encode([1,2,3,4,6,7]);
|
|
|
|
|
|
+ if ($data['is_search'] == 1) {
|
|
|
|
+ $page_type = json_encode([1, 2, 3, 4, 5, 6, 7]);
|
|
|
|
+ } else {
|
|
|
|
+ $page_type = json_encode([1, 2, 3, 4, 6, 7]);
|
|
}
|
|
}
|
|
// 0:未构建;1:已填写基础信息;2:已选择模板; action_id
|
|
// 0:未构建;1:已填写基础信息;2:已选择模板; action_id
|
|
- $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['page_type' => $page_type],['action_id' => 1]);
|
|
|
|
|
|
+ $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['page_type' => $page_type], ['action_id' => 1]);
|
|
if ($result) {
|
|
if ($result) {
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
} else {
|
|
} else {
|
|
@@ -1168,19 +1171,19 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
public function getWebsiteTemplateList(array $data): array
|
|
public function getWebsiteTemplateList(array $data): array
|
|
{
|
|
{
|
|
$where = [];
|
|
$where = [];
|
|
- if(isset($data['template_class_id']) && $data['template_class_id']){
|
|
|
|
|
|
+ if (isset($data['template_class_id']) && $data['template_class_id']) {
|
|
$where[] = ['template_class_id', '=', $data['template_class_id']];
|
|
$where[] = ['template_class_id', '=', $data['template_class_id']];
|
|
}
|
|
}
|
|
// 0:未构建 1:未应用 2:已应用 status
|
|
// 0:未构建 1:未应用 2:已应用 status
|
|
$templste_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
$templste_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
- if(empty($templste_info)){
|
|
|
|
|
|
+ if (empty($templste_info)) {
|
|
return Result::error('请先填写网站基础信息!');
|
|
return Result::error('请先填写网站基础信息!');
|
|
}
|
|
}
|
|
- if($templste_info['status'] == 2){
|
|
|
|
|
|
+ if ($templste_info['status'] == 2) {
|
|
return Result::error('网站已应用,不可再次修改!');
|
|
return Result::error('网站已应用,不可再次修改!');
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
|
|
|
+
|
|
|
|
+ if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
if (is_array($data['keyword'])) {
|
|
if (is_array($data['keyword'])) {
|
|
// 拼接多个模糊查询条件
|
|
// 拼接多个模糊查询条件
|
|
$query = Template::query();
|
|
$query = Template::query();
|
|
@@ -1195,12 +1198,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
}
|
|
}
|
|
$template_id = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first(['template_id', 'page_type']);
|
|
$template_id = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first(['template_id', 'page_type']);
|
|
// return Result::success($template_id);
|
|
// return Result::success($template_id);
|
|
- if(!empty($template_id['page_type']) && $templste_info['page_type'] != '[]' && is_string($templste_info['page_type'])){
|
|
|
|
|
|
+ if (!empty($template_id['page_type']) && $templste_info['page_type'] != '[]' && is_string($templste_info['page_type'])) {
|
|
$template_page = is_string($templste_info['page_type']) ? json_decode($templste_info['page_type'], true) : [];
|
|
$template_page = is_string($templste_info['page_type']) ? json_decode($templste_info['page_type'], true) : [];
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$template_page = [];
|
|
$template_page = [];
|
|
}
|
|
}
|
|
- if(!empty($template_id['template_id'])){
|
|
|
|
|
|
+ if (!empty($template_id['template_id'])) {
|
|
$result['template_id'] = $templste_info['template_id'];
|
|
$result['template_id'] = $templste_info['template_id'];
|
|
}
|
|
}
|
|
// 确保 $template_page 为有效数据,避免 SQL 注入风险,这里使用参数绑定
|
|
// 确保 $template_page 为有效数据,避免 SQL 注入风险,这里使用参数绑定
|
|
@@ -1215,7 +1218,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
}
|
|
}
|
|
if (empty($result['template']['data'])) {
|
|
if (empty($result['template']['data'])) {
|
|
- $result['template'] = Template::orderBy('updated_at','desc')
|
|
|
|
|
|
+ $result['template'] = Template::orderBy('updated_at', 'desc')
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
@@ -1228,19 +1231,19 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
public function chooseWebsiteTemplate(array $data): array
|
|
public function chooseWebsiteTemplate(array $data): array
|
|
{
|
|
{
|
|
$website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
$website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
- if(empty($website_template_info)){
|
|
|
|
|
|
+ if (empty($website_template_info)) {
|
|
return Result::error('请先填写网站基础信息!');
|
|
return Result::error('请先填写网站基础信息!');
|
|
}
|
|
}
|
|
// 0:未构建 1:未应用 2:已应用 status
|
|
// 0:未构建 1:未应用 2:已应用 status
|
|
- if($website_template_info['status'] == 2){
|
|
|
|
|
|
+ if ($website_template_info['status'] == 2) {
|
|
return Result::error('网站已应用,不可再次修改!');
|
|
return Result::error('网站已应用,不可再次修改!');
|
|
}
|
|
}
|
|
$template = Template::where('id', $data['template_id'])->first();
|
|
$template = Template::where('id', $data['template_id'])->first();
|
|
- if(empty($template)){
|
|
|
|
|
|
+ if (empty($template)) {
|
|
return Result::error('未查询到皮肤!');
|
|
return Result::error('未查询到皮肤!');
|
|
}
|
|
}
|
|
// 0:未构建;1:已填写基础信息;2:已选择模板; action_id
|
|
// 0:未构建;1:已填写基础信息;2:已选择模板; action_id
|
|
- $web_template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['template_id' => $data['template_id'],'action_id' => 2]);
|
|
|
|
|
|
+ $web_template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['template_id' => $data['template_id'], 'action_id' => 2]);
|
|
if ($web_template) {
|
|
if ($web_template) {
|
|
return Result::success($web_template);
|
|
return Result::success($web_template);
|
|
} else {
|
|
} else {
|
|
@@ -1255,25 +1258,25 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
public function saveWebsiteTemplate(array $data): array
|
|
public function saveWebsiteTemplate(array $data): array
|
|
{
|
|
{
|
|
$website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
$website_template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
- if(empty($website_template_info)){
|
|
|
|
|
|
+ if (empty($website_template_info)) {
|
|
return Result::error('请先填写网站基础信息!');
|
|
return Result::error('请先填写网站基础信息!');
|
|
}
|
|
}
|
|
// 0:未构建 1:未应用 2:已应用 status
|
|
// 0:未构建 1:未应用 2:已应用 status
|
|
- if($website_template_info['status'] == 2){
|
|
|
|
|
|
+ if ($website_template_info['status'] == 2) {
|
|
return Result::error('网站已应用,不可再次保存!');
|
|
return Result::error('网站已应用,不可再次保存!');
|
|
}
|
|
}
|
|
- if($website_template_info['action_id'] != 2){
|
|
|
|
|
|
+ if ($website_template_info['action_id'] != 2) {
|
|
return Result::error('请完成之前的步骤!');
|
|
return Result::error('请完成之前的步骤!');
|
|
}
|
|
}
|
|
$template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
$template_info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
- if(empty($template_info)){
|
|
|
|
- $template = WebsiteTemplate::insertGetId(['website_id' => $data['website_id'],'template_data' => $data['template_data']]);
|
|
|
|
- }else{
|
|
|
|
|
|
+ if (empty($template_info)) {
|
|
|
|
+ $template = WebsiteTemplate::insertGetId(['website_id' => $data['website_id'], 'template_data' => $data['template_data']]);
|
|
|
|
+ } else {
|
|
$template = WebsiteTemplate::where('website_id', $data['website_id'])->update(['template_data' => $data['template_data']]);
|
|
$template = WebsiteTemplate::where('website_id', $data['website_id'])->update(['template_data' => $data['template_data']]);
|
|
}
|
|
}
|
|
- if(empty($template)){
|
|
|
|
|
|
+ if (empty($template)) {
|
|
return Result::error('保存失败!');
|
|
return Result::error('保存失败!');
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return Result::success($template);
|
|
return Result::success($template);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1286,30 +1289,30 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
{
|
|
{
|
|
$where = [];
|
|
$where = [];
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
- if(empty($user)){
|
|
|
|
|
|
+ if (empty($user)) {
|
|
return Result::error('用户不存在!');
|
|
return Result::error('用户不存在!');
|
|
}
|
|
}
|
|
- if($user['type_id']!= 10000){
|
|
|
|
|
|
+ if ($user['type_id'] != 10000) {
|
|
$where['user_id'] = $data['user_id'];
|
|
$where['user_id'] = $data['user_id'];
|
|
}
|
|
}
|
|
- if(isset($data['title']) && $data['title']){
|
|
|
|
- array_push($where, ['title', 'like', '%'. $data['title']. '%']);
|
|
|
|
|
|
+ if (isset($data['title']) && $data['title']) {
|
|
|
|
+ array_push($where, ['title', 'like', '%' . $data['title'] . '%']);
|
|
}
|
|
}
|
|
- if(isset($data['website_id']) && $data['website_id']){
|
|
|
|
|
|
+ if (isset($data['website_id']) && $data['website_id']) {
|
|
$where['website_id'] = $data['website_id'];
|
|
$where['website_id'] = $data['website_id'];
|
|
}
|
|
}
|
|
// 状态:0:未审核 1:已审核 2:已拒绝
|
|
// 状态:0:未审核 1:已审核 2:已拒绝
|
|
$pageSize = isset($data['pageSize']) ? (int)$data['pageSize'] : 10; // 默认每页 10 条记录
|
|
$pageSize = isset($data['pageSize']) ? (int)$data['pageSize'] : 10; // 默认每页 10 条记录
|
|
$page = isset($data['page']) ? (int)$data['page'] : 1; // 默认第 1 页
|
|
$page = isset($data['page']) ? (int)$data['page'] : 1; // 默认第 1 页
|
|
- if(isset($data['ischeck']) && !empty($data['ischeck'])){
|
|
|
|
- if($data['ischeck'] == 1){
|
|
|
|
- $query = Company::whereIn('status', [0,2]);
|
|
|
|
- }else{
|
|
|
|
|
|
+ if (isset($data['ischeck']) && !empty($data['ischeck'])) {
|
|
|
|
+ if ($data['ischeck'] == 1) {
|
|
|
|
+ $query = Company::whereIn('status', [0, 2]);
|
|
|
|
+ } else {
|
|
$query = Company::where('status', 1);
|
|
$query = Company::where('status', 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$result = $query->where($where)->paginate($pageSize, ['*'], 'page', $page);
|
|
$result = $query->where($where)->paginate($pageSize, ['*'], 'page', $page);
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
return Result::error("暂无企业", 0);
|
|
return Result::error("暂无企业", 0);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
@@ -1330,7 +1333,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
if (isset($matches[1][0])) {
|
|
if (isset($matches[1][0])) {
|
|
//截取varchar240
|
|
//截取varchar240
|
|
$data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
$data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if ($data['keyword'] == '') {
|
|
if ($data['keyword'] == '') {
|
|
//提取标题+内容中的关键词
|
|
//提取标题+内容中的关键词
|
|
@@ -1347,10 +1350,10 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
$data['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
|
|
$data['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
|
|
}
|
|
}
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
- if(empty($user)){
|
|
|
|
|
|
+ if (empty($user)) {
|
|
return Result::error('用户不存在!');
|
|
return Result::error('用户不存在!');
|
|
}
|
|
}
|
|
- if($user['type_id']== 10000){
|
|
|
|
|
|
+ if ($user['type_id'] == 10000) {
|
|
$data['status'] = 1;
|
|
$data['status'] = 1;
|
|
}
|
|
}
|
|
$result = Company::insertGetId($data);
|
|
$result = Company::insertGetId($data);
|
|
@@ -1376,7 +1379,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
if (isset($matches[1][0])) {
|
|
if (isset($matches[1][0])) {
|
|
//截取varchar240
|
|
//截取varchar240
|
|
$data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
$data['imgurl'] = substr($matches[1][0], 0, 240);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if ($data['keyword'] == '') {
|
|
if ($data['keyword'] == '') {
|
|
//提取标题+内容中的关键词
|
|
//提取标题+内容中的关键词
|
|
@@ -1393,12 +1396,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
$data['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
|
|
$data['introduce'] = substr(str_replace(' ', '', strip_tags($data['content'])), 0, 100);
|
|
}
|
|
}
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
- if(empty($user)){
|
|
|
|
|
|
+ if (empty($user)) {
|
|
return Result::error('用户不存在!');
|
|
return Result::error('用户不存在!');
|
|
}
|
|
}
|
|
- if($user['type_id']== 10000){
|
|
|
|
|
|
+ if ($user['type_id'] == 10000) {
|
|
$data['status'] = 1;
|
|
$data['status'] = 1;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$data['status'] = 0;
|
|
$data['status'] = 0;
|
|
}
|
|
}
|
|
$result = Company::where('id', $data['id'])->update($data);
|
|
$result = Company::where('id', $data['id'])->update($data);
|
|
@@ -1430,22 +1433,22 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
public function checkCompany(array $data): array
|
|
public function checkCompany(array $data): array
|
|
{
|
|
{
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
$user = User::where('id', $data['user_id'])->first();
|
|
- if(empty($user)){
|
|
|
|
|
|
+ if (empty($user)) {
|
|
return Result::error('用户不存在!');
|
|
return Result::error('用户不存在!');
|
|
}
|
|
}
|
|
$company = Company::where('id', $data['id'])->first();
|
|
$company = Company::where('id', $data['id'])->first();
|
|
- if(empty($company)){
|
|
|
|
|
|
+ if (empty($company)) {
|
|
return Result::error('企业不存在!');
|
|
return Result::error('企业不存在!');
|
|
}
|
|
}
|
|
// 状态:0:未审核 1:已审核 2:已拒绝
|
|
// 状态:0:未审核 1:已审核 2:已拒绝
|
|
- if($company['status'] == 0 || $company['status'] == 1){
|
|
|
|
|
|
+ if ($company['status'] == 0 || $company['status'] == 1) {
|
|
$result = Company::where('id', $data['id'])->update(['status' => $data['status']]);
|
|
$result = Company::where('id', $data['id'])->update(['status' => $data['status']]);
|
|
- }else{
|
|
|
|
- $result = Company::where('id', $data['id'])->update(['status' => $data['status'],'reject_reason'=> $data['reject_reason']]);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ $result = Company::where('id', $data['id'])->update(['status' => $data['status'], 'reject_reason' => $data['reject_reason']]);
|
|
}
|
|
}
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
return Result::error('审核失败!');
|
|
return Result::error('审核失败!');
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1457,9 +1460,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
public function getCompanyInfo(array $data): array
|
|
public function getCompanyInfo(array $data): array
|
|
{
|
|
{
|
|
$result = Company::where('id', $data['id'])->first();
|
|
$result = Company::where('id', $data['id'])->first();
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
return Result::error('企业不存在!');
|
|
return Result::error('企业不存在!');
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
}
|
|
}
|