|
@@ -28,7 +28,9 @@ use App\Model\Link;
|
|
|
use App\Model\FooterCategory;
|
|
|
|
|
|
use function Hyperf\Support\retry;
|
|
|
-
|
|
|
+use App\Model\Company;
|
|
|
+use Hyperf\Paginator\Paginator;
|
|
|
+use App\Model\User;
|
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
|
{
|
|
@@ -1271,4 +1273,146 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::success($template);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 企业管理
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getCompanyList(array $data): array
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ if($user['type_id']!= 10000){
|
|
|
+ $where['user_id'] = $data['user_id'];
|
|
|
+ }
|
|
|
+ if(isset($data['title']) && $data['title']){
|
|
|
+ array_push($where, ['title', 'like', '%'. $data['title']. '%']);
|
|
|
+ }
|
|
|
+ if(isset($data['website_id']) && $data['website_id']){
|
|
|
+ $where['website_id'] = $data['website_id'];
|
|
|
+ }
|
|
|
+ // 状态:0:未审核 1:已审核 2:已拒绝
|
|
|
+ $pageSize = isset($data['pageSize']) ? (int)$data['pageSize'] : 10; // 默认每页 10 条记录
|
|
|
+ $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{
|
|
|
+ $query = Company::where('status', 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result = $query->where($where)->paginate($pageSize, ['*'], 'page', $page);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("暂无企业", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 添加企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function addCompany(array $data): array
|
|
|
+ {
|
|
|
+ $data['category_id'] = isset($data['cat_arr_id']) ? end($data['cat_arr_id']) : '';
|
|
|
+ $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ if($user['type_id']== 10000){
|
|
|
+ $data['status'] = 1;
|
|
|
+ }
|
|
|
+ $result = Company::insertGetId($data);
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('添加失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 更新企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function upCompany(array $data): array
|
|
|
+ {
|
|
|
+ $data['category_id'] = isset($data['cat_arr_id']) ? end($data['cat_arr_id']) : '';
|
|
|
+ $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ if($user['type_id']== 10000){
|
|
|
+ $data['status'] = 1;
|
|
|
+ }else{
|
|
|
+ $data['status'] = 0;
|
|
|
+ }
|
|
|
+ $result = Company::where('id', $data['id'])->update($data);
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('修改失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 删除企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function delCompany(array $data): array
|
|
|
+ {
|
|
|
+ $result = Company::where('id', $data['id'])->delete();
|
|
|
+ if ($result) {
|
|
|
+ return Result::success($result);
|
|
|
+ } else {
|
|
|
+ return Result::error('删除失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 审核企业
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function checkCompany(array $data): array
|
|
|
+ {
|
|
|
+ $user = User::where('id', $data['user_id'])->first();
|
|
|
+ if(empty($user)){
|
|
|
+ return Result::error('用户不存在!');
|
|
|
+ }
|
|
|
+ if($user['type_id'] != 10000){
|
|
|
+ return Result::error('用户权限不足!');
|
|
|
+ }
|
|
|
+ $company = Company::where('id', $data['id'])->first();
|
|
|
+ if(empty($company)){
|
|
|
+ return Result::error('企业不存在!');
|
|
|
+ }
|
|
|
+ // 状态:0:未审核 1:已审核 2:已拒绝
|
|
|
+ if($company['status'] == 0){
|
|
|
+ switch ($data['status']) {
|
|
|
+ case 0:
|
|
|
+ return Result::error('请选择审核状态!');
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ $result = Company::where('id', $data['id'])->update(['status' => $data['status']]);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ $result = Company::where('id', $data['id'])->update(['status' => $data['status'],'reject_reason'=> $data['reject_reason']]);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return Result::error('请选择审核状态!');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error('企业已审核!');
|
|
|
+ }
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('审核失败!');
|
|
|
+ }else{
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|