Commit 87afbfb8 by 杨树贤

fix

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