Commit 87afbfb8 by 杨树贤

fix

parent 1ed72a77
...@@ -10,7 +10,6 @@ use Illuminate\Support\Facades\Validator; ...@@ -10,7 +10,6 @@ use Illuminate\Support\Facades\Validator;
class SupplierAccountValidator class SupplierAccountValidator
{ {
//保存相关的验证,别问我为什么不用laravel自带的form-request类 //保存相关的验证,别问我为什么不用laravel自带的form-request类
//因为控制器那边已经被之前的人魔改的难用的一比,而且控制器那边还接收了一大堆统一变量
public function checkSave($request) public function checkSave($request)
{ {
//整理下请求数据 //整理下请求数据
...@@ -33,15 +32,16 @@ class SupplierAccountValidator ...@@ -33,15 +32,16 @@ class SupplierAccountValidator
if ($validator->fails()) { if ($validator->fails()) {
return $validator->errors()->first(); return $validator->errors()->first();
} }
$model = new SupplierAccountModel();
if (empty($account['id'])) { if (empty($account['id'])) {
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
$yunxinChannelUid = $supplierModel->where('supplier_code', $yunxinChannelUid = $supplierModel->where(
$account['supplier_code'])->value('yunxin_channel_uid'); 'supplier_code',
$account['supplier_code']
)->value('yunxin_channel_uid');
if (empty($yunxinChannelUid)) { if (empty($yunxinChannelUid)) {
//return '该供应商没有绑定SKU采购,请完善相关信息'; //return '该供应商没有绑定SKU采购,请完善相关信息';
} }
$model = new SupplierAccountModel();
$supplierCount = $model->where('supplier_code', $account['supplier_code']) $supplierCount = $model->where('supplier_code', $account['supplier_code'])
->count(); ->count();
if ($supplierCount > 0) { if ($supplierCount > 0) {
...@@ -52,6 +52,13 @@ class SupplierAccountValidator ...@@ -52,6 +52,13 @@ class SupplierAccountValidator
if ($mobileCount > 0) { if ($mobileCount > 0) {
return '该手机号已经被注册'; return '该手机号已经被注册';
} }
} else {
$supplierCount = $model->where('id', '!=', $account['id'])
->where('supplier_code', $account['supplier_code'])
->count();
if ($supplierCount > 0) {
return '该供应商已经存在账号';
}
} }
return true; return true;
......
...@@ -101,6 +101,13 @@ class SupplierValidator ...@@ -101,6 +101,13 @@ class SupplierValidator
return null; return null;
} }
if (empty($supplierId)) {
$count = SupplierChannelModel::where('supplier_name', $validateData['supplier_name'])->count();
if ($count) {
return "该供应商名称已经存在,请核验后再提交";
}
}
$rules = [ $rules = [
'supplier_type' => 'required', 'supplier_type' => 'required',
'supplier_name' => 'required', 'supplier_name' => 'required',
......
...@@ -96,8 +96,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -96,8 +96,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
SupplierAccountService::autoCreateYunxinAccount(18708); SupplierChannelModel::where('supplier_id', '18715')->delete();
// DataService::initSupplierNationId();
// DataService::initSupplierReceiptNationId(); // DataService::initSupplierReceiptNationId();
// SupplierAccountService::initYunxinAccountName(); // SupplierAccountService::initYunxinAccountName();
// DataService::syncSupplierToErp(); // DataService::syncSupplierToErp();
......
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