Commit 41d9316c by 杨树贤

供应商审核接口

parent 78da315b
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Services\AdminUserService;
use App\Http\Services\SupplierService; use App\Http\Services\SupplierService;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
......
...@@ -200,7 +200,7 @@ class SupplierApiController extends Controller ...@@ -200,7 +200,7 @@ class SupplierApiController extends Controller
} }
//获取供应商信息变更记录 //获取供应商列表
public function GetSupplierList(Request $request) public function GetSupplierList(Request $request)
{ {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
...@@ -216,6 +216,18 @@ class SupplierApiController extends Controller ...@@ -216,6 +216,18 @@ class SupplierApiController extends Controller
$this->response(0, 'ok', $list['data'], $list['total']); $this->response(0, 'ok', $list['data'], $list['total']);
} }
//获取供应商详情,目前是给审核小程序用的
public function GetSupplierAuditDetail(Request $request)
{
$supplierId = $request->input('supplier_id');
if (!$supplierId) {
$this->response(-1, '供应商id不能为空');
}
$supplier = (new SupplierService())->getSupplier($supplierId, true);
$supplier = (new SupplierTransformer())->transformSupplierDetail($supplier);
$this->response(0, 'ok', $supplier);
}
public function DisableSupplier($request) public function DisableSupplier($request)
{ {
//禁用不是直接修改为无法交易,而是改为审核中,然后审核通过后,变成无法交易 //禁用不是直接修改为无法交易,而是改为审核中,然后审核通过后,变成无法交易
......
...@@ -39,8 +39,10 @@ class Controller extends BaseController ...@@ -39,8 +39,10 @@ class Controller extends BaseController
'code' => $errCode[0], 'code' => $errCode[0],
'err_code' => $errCode[0], 'err_code' => $errCode[0],
'err_msg' => $errCode[1], 'err_msg' => $errCode[1],
'msg' => $errCode[1],
'data' => !empty($errCode[2]) ? $errCode[2] : '', 'data' => !empty($errCode[2]) ? $errCode[2] : '',
'count' => $count, 'count' => $count,
'total' => $count,
]); ]);
exit(); exit();
} else { } else {
...@@ -48,8 +50,10 @@ class Controller extends BaseController ...@@ -48,8 +50,10 @@ class Controller extends BaseController
'err_code' => $errCode, 'err_code' => $errCode,
'code' => $errCode, 'code' => $errCode,
'err_msg' => $errMsg, 'err_msg' => $errMsg,
'msg' => $errMsg,
'data' => $data, 'data' => $data,
'count' => $count, 'count' => $count,
'total' => $count,
]); ]);
exit(); exit();
} }
......
...@@ -49,10 +49,8 @@ class SupplierFilter ...@@ -49,10 +49,8 @@ class SupplierFilter
} }
if (!empty($map['stockup_type'])) { if (!empty($map['stockup_type'])) {
$regexStr = '(' . str_replace(',', '|', $map['stockup_type']) . ')'; $regexStr = '(' . str_replace(',', '|', $map['stockup_type']) . ')';
// $query->where('stockup_type', 'like', "%{$map['stockup_type']}%");
$query->whereRaw("stockup_type REGEXP '${regexStr}'"); $query->whereRaw("stockup_type REGEXP '${regexStr}'");
} }
if (!empty($map['purchase_uid'])) { if (!empty($map['purchase_uid'])) {
$query->where('purchase_uid', $map['purchase_uid']); $query->where('purchase_uid', $map['purchase_uid']);
} }
...@@ -123,6 +121,19 @@ class SupplierFilter ...@@ -123,6 +121,19 @@ class SupplierFilter
} }
}); });
} }
//获取待审核,待复审的数据
if (!empty($map['need_audit'])) {
if (checkPerm('ReviewSupplier')) {
$query = $query->whereIn('status', [
SupplierChannelModel::STATUS_IN_REVIEW,
SupplierChannelModel::STATUS_NEED_REVIEW
]);
} else {
$query = $query->where('status', SupplierChannelModel::STATUS_IN_REVIEW);
}
}
//默认过滤带有-1字符串的供应商名称的数据 //默认过滤带有-1字符串的供应商名称的数据
$query->whereRaw('supplier_name NOT LIKE "%-1"'); $query->whereRaw('supplier_name NOT LIKE "%-1"');
if (config('website.domain') == 'liexin.net' && !in_array(request()->user->userId, [ if (config('website.domain') == 'liexin.net' && !in_array(request()->user->userId, [
...@@ -136,6 +147,7 @@ class SupplierFilter ...@@ -136,6 +147,7 @@ class SupplierFilter
])) { ])) {
$query->where('supplier_channel.supplier_id', '>', 12211); $query->where('supplier_channel.supplier_id', '>', 12211);
} }
return $query; return $query;
} }
......
...@@ -3,8 +3,11 @@ ...@@ -3,8 +3,11 @@
namespace App\Http\Controllers\Sync; namespace App\Http\Controllers\Sync;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Http\Services\AdminUserService;
use App\Http\Services\SupplierService; use App\Http\Services\SupplierService;
use App\Http\Services\SyncSupplierService; use App\Http\Services\SyncSupplierService;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
...@@ -44,4 +47,28 @@ class SupplierSyncController extends BaseSyncController ...@@ -44,4 +47,28 @@ class SupplierSyncController extends BaseSyncController
$this->syncResponse(0, '同步一体化信息成功'); $this->syncResponse(0, '同步一体化信息成功');
} }
//获取供应商需要审核的数量
public function GetSupplierNeedAuditCount(Request $request)
{
$userId = $request->input('user_id');
if (!$userId) {
$this->response(-1,'user_id不能为空');
}
$codeId = (new AdminUserService())->getCodeIdsByUserId($userId);
request()->merge(['user'=>(object)[
'userId' => $userId,
'codeId' => $codeId,
]]);
// request()->user->userId = $userId;
// request()->user->codeId = $codeId;
$model = new SupplierChannelModel();
$query = $model->orderBy('update_time', 'desc');
$filter = new SupplierFilter();
$params = $request->except('user');
$params['need_audit'] = 1;
$query = $filter->listFilter($params, $query);
$count = $query->count();
$this->response(0, 'ok', $count);
}
} }
...@@ -38,7 +38,7 @@ class CheckLogin ...@@ -38,7 +38,7 @@ class CheckLogin
if (!$userId || !$skey || (string)((int)$userId) != $userId || !preg_match('/^[a-zA-Z0-9]+$/', $skey)) { if (!$userId || !$skey || (string)((int)$userId) != $userId || !preg_match('/^[a-zA-Z0-9]+$/', $skey)) {
if ($isApi) { if ($isApi) {
return ["errcode" => 401, "errmsg" => "没有登录"]; return ["errcode" => 101, "errmsg" => "没有登录"];
} }
return redirect($login['login'] . '?redirect=' . urlencode($request->fullUrl())); return redirect($login['login'] . '?redirect=' . urlencode($request->fullUrl()));
} }
...@@ -69,7 +69,7 @@ class CheckLogin ...@@ -69,7 +69,7 @@ class CheckLogin
} else { } else {
$rsp = curl($login['dingtalk_check'], ['token' => trim($request->input('token'))]); $rsp = curl($login['dingtalk_check'], ['token' => trim($request->input('token'))]);
if (!$rsp) { if (!$rsp) {
["errcode" => 401, "errmsg" => "登录失效"]; return ["errcode" => 101, "errmsg" => "登录失效"];
} }
$ret = json_decode($rsp); $ret = json_decode($rsp);
......
...@@ -53,6 +53,12 @@ class AdminUserService ...@@ -53,6 +53,12 @@ class AdminUserService
return UserInfoModel::where('email', $email)->value('userId'); return UserInfoModel::where('email', $email)->value('userId');
} }
public function getCodeIdsByUserId($userId)
{
$intraCodeModel = new IntracodeModel();
return $intraCodeModel->where('admin_id', $userId)->value('code_id');
}
public function getCodeIdsByUserIds($userIds) public function getCodeIdsByUserIds($userIds)
{ {
$intraCodeModel = new IntracodeModel(); $intraCodeModel = new IntracodeModel();
......
...@@ -20,10 +20,14 @@ class SupplierService ...@@ -20,10 +20,14 @@ class SupplierService
public $newSupplierId = 0; public $newSupplierId = 0;
public function getSupplier($supplierId) public function getSupplier($supplierId, $getExtraInfo = false)
{ {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
$supplier = $model->where('supplier_id', $supplierId)->with('contact')->first(); $query = $model->where('supplier_id', $supplierId)->with('contact');
if ($getExtraInfo) {
$query->with(['attachment', 'receipt']);
}
$supplier = $query->first();
$transformer = new SupplierTransformer(); $transformer = new SupplierTransformer();
$supplier = $transformer->transformInfo($supplier); $supplier = $transformer->transformInfo($supplier);
return $supplier ? $supplier->toArray() : []; return $supplier ? $supplier->toArray() : [];
...@@ -188,7 +192,7 @@ class SupplierService ...@@ -188,7 +192,7 @@ class SupplierService
if ($needAudit) { if ($needAudit) {
$channel['status'] = SupplierChannelModel::STATUS_PENDING; $channel['status'] = SupplierChannelModel::STATUS_PENDING;
}else{ } else {
//不需要审核的话,那么还要直接同步到金蝶 //不需要审核的话,那么还要直接同步到金蝶
$syncService = new SyncSupplierService(); $syncService = new SyncSupplierService();
$syncService->syncSupplierToErp($supplierId); $syncService->syncSupplierToErp($supplierId);
......
...@@ -45,6 +45,7 @@ class SupplierTransformer ...@@ -45,6 +45,7 @@ class SupplierTransformer
$supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region'], '暂无'); $supplier['region_name'] = array_get(config('fixed.Region'), $supplier['region'], '暂无');
$supplier['contact_num'] = $this->getContactNum($supplier['supplier_id']); $supplier['contact_num'] = $this->getContactNum($supplier['supplier_id']);
$supplier['has_sku'] = $supplier['sku_num'] ? '是' : '否'; $supplier['has_sku'] = $supplier['sku_num'] ? '是' : '否';
$supplier['is_business_abnormal_name'] = $supplier['is_business_abnormal'] == 1 ? '是' : '否';
if (isset($supplier['attachment'])) { if (isset($supplier['attachment'])) {
$supplier['has_quality_assurance_agreement'] = $this->checkHasQualityAssuranceAgreement($supplier['attachment']) ? '有' : '无'; $supplier['has_quality_assurance_agreement'] = $this->checkHasQualityAssuranceAgreement($supplier['attachment']) ? '有' : '无';
} else { } else {
...@@ -61,6 +62,7 @@ class SupplierTransformer ...@@ -61,6 +62,7 @@ class SupplierTransformer
$log = $logModel->where('supplier_id', $supplier['supplier_id']) $log = $logModel->where('supplier_id', $supplier['supplier_id'])
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first(); ->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
$supplier['last_update_name'] = $log ? $log['admin_name'] : ''; $supplier['last_update_name'] = $log ? $log['admin_name'] : '';
$supplier['last_update_time'] = $log ? date('Y-m-d H:i:s', $log['add_time']) : '';
//黑名单 //黑名单
if (!empty($supplier['blacklist'])) { if (!empty($supplier['blacklist'])) {
$supplier['blacklist_name'] = $supplier['blacklist']['blacklist_name']; $supplier['blacklist_name'] = $supplier['blacklist']['blacklist_name'];
...@@ -333,4 +335,14 @@ class SupplierTransformer ...@@ -333,4 +335,14 @@ class SupplierTransformer
return $suppliers; return $suppliers;
} }
//供应商审核详情
public function transformSupplierDetail($supplier)
{
$supplier['contact'] = $supplier['contact'] ? (new SupplierContactTransformer())->transformList($supplier['contact']) : [];
$supplier['receipt'] = $supplier['receipt'] ? (new ReceiptTransformer())->transformList($supplier['receipt']) : [];
$supplier['attachment'] = $supplier['attachment'] ? (new SupplierAttachmentTransformer())->transformList($supplier['attachment']) : [];
return $supplier;
}
} }
\ No newline at end of file
...@@ -174,6 +174,9 @@ function Autograph() ...@@ -174,6 +174,9 @@ function Autograph()
function checkPerm($perm) function checkPerm($perm)
{ {
$perms = request()->perms; $perms = request()->perms;
if ($perms === null) {
return true;
}
return in_array($perm, $perms); return in_array($perm, $perms);
} }
......
...@@ -50,7 +50,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () { ...@@ -50,7 +50,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/sku_upload_log/{key}', 'SkuUploadLogApiController@Entrance'); Route::match(['get', 'post'], '/api/sku_upload_log/{key}', 'SkuUploadLogApiController@Entrance');
}); });
//提供给其它系统使用的接口 //提供给其它系统使用的接口,不需要验证那种
Route::group(['middleware' => ['external'], 'namespace' => 'Api'], function () { Route::group(['middleware' => ['external'], 'namespace' => 'Api'], function () {
Route::get('/api/external/searchSupplier', 'ExternalApiController@searchSupplier'); Route::get('/api/external/searchSupplier', 'ExternalApiController@searchSupplier');
}); });
...@@ -59,6 +59,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Api'], function () { ...@@ -59,6 +59,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Api'], function () {
Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () { Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () {
//这个接口是用来接收同步结果,同时这个接口也是接收一体化那边的修改 //这个接口是用来接收同步结果,同时这个接口也是接收一体化那边的修改
Route::any('/sync/unitedData/syncResult', 'SupplierSyncController@syncUniteResult'); Route::any('/sync/unitedData/syncResult', 'SupplierSyncController@syncUniteResult');
Route::get('/sync/audit/GetSupplierNeedAuditCount', 'SupplierSyncController@GetSupplierNeedAuditCount');
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
......
...@@ -65,6 +65,12 @@ class SupplierChannelModel extends Model ...@@ -65,6 +65,12 @@ class SupplierChannelModel extends Model
return $this->hasMany(SupplierPayTypeModel::class, 'supplier_id', 'supplier_id'); return $this->hasMany(SupplierPayTypeModel::class, 'supplier_id', 'supplier_id');
} }
//银行信息
public function receipt()
{
return $this->hasMany(SupplierReceiptModel::class, 'supplier_id', 'supplier_id');
}
//获取正式供应商 //获取正式供应商
public function getOfficialSuppliers() public function getOfficialSuppliers()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment