Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

杨树贤 / liexin_supplier

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Find file
Normal viewHistoryPermalink
Switch branch/tag
  • liexin_supplier
  • app
  • Http
  • Controllers
  • Api
  • CommonApiController.php
CommonApiController.php 3.12 KB
mushishixian's avatar
temp
cd06e008
 
mushishixian committed 4 years ago
1 2 3 4 5
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
mushishixian's avatar
修复bug
901d9859
 
mushishixian committed 4 years ago
6
use App\Http\Services\AdminUserService;
杨树贤's avatar
暂存
98f56bd5
 
杨树贤 committed 2 years ago
7
use App\Http\Services\CompanyService;
杨树贤's avatar
优化主营品牌选择
f3662775
 
杨树贤 committed 2 years ago
8
use App\Http\Services\StandardBrandService;
mushishixian's avatar
temp
cd06e008
 
mushishixian committed 4 years ago
9
use App\Model\BrandModel;
mushishixian's avatar
附件认证规则修改
35bad2ca
 
mushishixian committed 3 years ago
10
use App\Model\StandardBrandModel;
杨树贤's avatar
修改限制
edad517f
 
杨树贤 committed 2 years ago
11
use App\Model\SupplierChannelModel;
mushishixian's avatar
temp
cd06e008
 
mushishixian committed 4 years ago
12 13
use Illuminate\Http\Request;
use GuzzleHttp\Client;
mushishixian's avatar
temp
c50c7213
 
mushishixian committed 4 years ago
14
use Illuminate\Support\Facades\DB;
mushishixian's avatar
temp
cd06e008
 
mushishixian committed 4 years ago
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

//通用API,比如获取品牌列表,分类列表等
class CommonApiController extends Controller
{
    public function Entrance(Request $request, $id)
    {
        $this->$id($request, $id);
    }


    //获取所有品牌
    public function getBrandList($request)
    {
        $type = $request->get('type');
        //如果传的type=0,默认给自营
        $type = $type ?: 1;
        $model = new BrandModel();
        $brandList = $model->getBrandListByType($type);
杨树贤's avatar
暂存
98f56bd5
 
杨树贤 committed 2 years ago
33
        $this->response(0, 'ok', $brandList);
mushishixian's avatar
temp
cd06e008
 
mushishixian committed 4 years ago
34 35
    }

mushishixian's avatar
标准品牌
65ee9685
 
mushishixian committed 3 years ago
36 37 38
    //获取标准品牌
    public function getStandardBrandList($request)
    {
杨树贤's avatar
优化主营品牌选择
f3662775
 
杨树贤 committed 2 years ago
39 40 41 42 43 44 45 46 47 48 49 50 51
        $list = (new StandardBrandService())->getStandardBrandList($request->all());
        $data = array_get($list, 'data');
        $lastPage = array_get($list, 'last_page');
        $total = array_get($list, 'total');
        echo json_encode([
            'err_code' => 0,
            'err_msg' => 'ok',
            'total' => $total,
            'count' => $total,
            'data' => $data,
            'last_page' => $lastPage
        ]);
        exit();
mushishixian's avatar
附件认证规则修改
35bad2ca
 
mushishixian committed 3 years ago
52 53
    }

mushishixian's avatar
temp
c50c7213
 
mushishixian committed 4 years ago
54 55 56 57 58 59 60 61 62 63 64
    private function SearchBrand($request)
    {
        $brandName = $request->input('brand_name');
        $type = $request->input('type');
        if (empty($type)) {
            $type = 1;
        }
        $connection = $type == 1 ? 'spu' : 'self';
        $table = $type == 1 ? 'brand' : 'brand';
        $db = DB::connection($connection)->table($table)->where('status', '1');
        if ($brandName) {
mushishixian's avatar
fix
6ea2d53e
 
mushishixian committed 4 years ago
65
            $db = $db->where('brand_name', 'like', $brandName . '%');
mushishixian's avatar
temp
c50c7213
 
mushishixian committed 4 years ago
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
        }
        $count = $db->count();
        $list = $db->select('brand_name', 'brand_id')->paginate(17);
        $list = $list ? $list->toArray() : [];
        $data = array_get($list, 'data');
        $lastPage = array_get($list, 'last_page');
        echo json_encode([
            'errcode' => 0,
            'errmsg' => 'ok',
            'total' => $count,
            'count' => $count,
            'data' => $data,
            'last_page' => $lastPage
        ]);
    }

杨树贤's avatar
暂存
98f56bd5
 
杨树贤 committed 2 years ago
82
    public function checkCompanyInfo($request)
mushishixian's avatar
修复bug
901d9859
 
mushishixian committed 4 years ago
83
    {
杨树贤's avatar
暂存
98f56bd5
 
杨树贤 committed 2 years ago
84 85 86
        //请求天眼查校验接口
        $supplierName = $request->get('supplier_name');
        $taxNumber = $request->get('tax_number');
杨树贤's avatar
校验
f0d87da8
 
杨树贤 committed 2 years ago
87
        $region = $request->get('region');
杨树贤's avatar
修改限制
edad517f
 
杨树贤 committed 2 years ago
88 89 90 91 92 93 94 95
        $company = [];
        if (in_array($region, config('field.NeedCheckCompanyRegion'))) {
            $regionType = $region == SupplierChannelModel::REGION_CN ? 1 : 2;
            $company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber, $regionType);
            if (!$company) {
                $this->response(-1, '获取不到公司');
            }
        }else{
杨树贤's avatar
欧美日韩不需要校验公司
cd322132
 
杨树贤 committed 2 years ago
96
            $this->response(-2, '供应商跳过天眼查校验');
杨树贤's avatar
暂存
98f56bd5
 
杨树贤 committed 2 years ago
97
        }
杨树贤's avatar
修改限制
edad517f
 
杨树贤 committed 2 years ago
98

杨树贤's avatar
暂存
98f56bd5
 
杨树贤 committed 2 years ago
99 100
        $this->response(0, 'ok', $company);

mushishixian's avatar
修复bug
901d9859
 
mushishixian committed 4 years ago
101 102
    }

mushishixian's avatar
temp
cd06e008
 
mushishixian committed 4 years ago
103
}