Commit 73ffd048 by 杨树贤

支持供应商国家/地区

parent 0f9ae83d
......@@ -103,6 +103,7 @@ class SupplierApiController extends Controller
'sign_com_id',
'sku_optional_batch',
'nation_id',
];
public function Entrance(Request $request, $id)
......
......@@ -63,7 +63,7 @@ class SupplierReceiptApiController extends Controller
'remark',
'nation_id',
'intermediary_bank',
//'international_code'
//'nation_id'
]);
$receipt = array_map('trim', $receipt);
$receipt['account_adderss'] = empty($receipt['account_adderss']) ? ' ' : $receipt['account_adderss'];
......
......@@ -179,13 +179,13 @@ class SupplierController extends Controller
'value' => $userId,
];
}
$this->data['nationList'] = NationModel::getNationList();
$defaultPurchaseUid = $intraCodeModel->getCodeIdByUserName(config('field.DefaultPurchaseName'));
$this->data['operate'] = 'add';
$this->data['default_purchase_uid'] = $defaultPurchaseUid;
//省市区数据放到script模板
$regionService = new RegionService();
$this->data['region_data'] = $regionService->getCityRegionData();
$this->data['nationList'] = NationModel::pluck('name_cn', 'nation_id')->toArray();
$this->data['brand_init_value'] = [];
$this->data['agency_brand_init_value'] = [];
//编辑
......@@ -225,6 +225,7 @@ class SupplierController extends Controller
//省市区数据放到script模板
$regionService = new RegionService();
$this->data['region_data'] = $regionService->getCityRegionData();
$this->data['nationList'] = NationModel::getNationList();
//编辑
$this->data['title'] = '编辑供应商';
$supplierId = $request->get('supplier_id');
......
......@@ -7,7 +7,6 @@ use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierService;
use App\Http\Services\SupplierStatisticsService;
use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel;
use App\Model\NationModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierReceiptModel;
......@@ -48,6 +47,7 @@ class SupplierReceiptController extends Controller
{
$this->data['title'] = '添加供应商银行';
$this->data['nationList'] = NationModel::pluck('name_cn','nation_id')->toArray();
$this->data['internationalCodeList'] = NationModel::getNationList();
return $this->view('添加供应商银行');
}
......@@ -62,6 +62,7 @@ class SupplierReceiptController extends Controller
$this->data['nationList'] = NationModel::pluck('name_cn','nation_id')->toArray();
$this->data['title'] = '修改供应商银行';
$this->data['view'] = 'AddSupplierReceipt';
$this->data['internationalCodeList'] = NationModel::getNationList();
return $this->view('修改供应商银行');
}
......
......@@ -29,6 +29,7 @@ use App\Model\SupplierAttachmentsModel;
use App\Model\StandardBrandMappingModel;
use App\Model\Purchase\PurchaseOrderModel;
use App\Http\Transformers\SupplierTransformer;
use App\Model\NationModel;
//这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多
class DataService
......@@ -807,4 +808,67 @@ class DataService
continue;
}
}
public static function repairNationInternationalCode()
{
//读取json文件
$filePath = public_path('data') . DIRECTORY_SEPARATOR . 'countries_list.json';
$json = file_get_contents($filePath);
$data = json_decode($json, true);
$nationList = NationModel::all()->toArray();
foreach ($nationList as $item) {
$nation = array_filter($data, function ($nation) use ($item) {
return $nation['cn'] == $item['name_cn'] || $nation['en'] == $item['name_en'];
});
$nation = array_values($nation);
if (empty($nation)) {
continue;
}
$nation = $nation[0];
NationModel::where('nation_id', $item['nation_id'])->update([
'nation_id' => $nation['abb2'],
]);
}
}
public static function initSupplierNationId()
{
ini_set('memory_limit', '2048M');
$supplierList = SupplierChannelModel::where('is_type', 0)->get()->toArray();
foreach ($supplierList as $supplier) {
$supplier['nation_id'] = 0;
switch ($supplier['region']) {
case 2:
$supplier['nation_id'] = 36;
break;
case 4:
$supplier['nation_id'] = 194;
break;
case 6:
$supplier['nation_id'] = 195;
break;
}
SupplierChannelModel::where('supplier_id', $supplier['supplier_id'])->update([
'nation_id' => $supplier['nation_id'],
]);
}
}
public static function initSupplierReceiptNationId()
{
ini_set('memory_limit', '2048M');
$supplierReceiptList = SupplierReceiptModel::where('ration_id', 0)->get()->toArray();
foreach ($supplierReceiptList as $supplierReceipt) {
$supplierReceipt['nation_id'] = 0;
$receiptType = $supplierReceipt['receipt_type'];
switch ($receiptType) {
case 1:
$supplierReceipt['nation_id'] = 36;
break;
}
SupplierReceiptModel::where('receipt_id', $supplierReceipt['receipt_id'])->update([
'nation_id' => $supplierReceipt['nation_id'],
]);
}
}
}
......@@ -30,7 +30,7 @@ class ReceiptValidator
$rules["bank_adderss"] = 'required';
$rules["nation_id"] = 'required';
$rules['account_no'] = 'required|alpha_num';
//$rules["international_code"] = 'required';
//$rules["nation_id"] = 'required';
}
$messages = $this->messages();
$validator = Validator::make($receipt, $rules, $messages);
......@@ -63,8 +63,7 @@ class ReceiptValidator
'account_name.required' => '账户名称 不能为空',
'certificate.required' => '银行信息凭证 不能为空',
'account_adderss.required' => '银行地址 不能为空',
'nation_id.required' => '银行国家 不能为空',
//'international_code.required' => '国际代码 不能为空',
'nation_id.required' => '国家/地区 不能为空',
];
}
}
......@@ -3,14 +3,14 @@
namespace App\Http\Validators;
use App\Http\Services\CompanyService;
use App\Http\Services\SupplierPayTypeService;
use App\Model\SupplierAttachmentsModel;
use Carbon\Carbon;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Model\SupplierReceiptModel;
use Carbon\Carbon;
use Validator;
use App\Http\Services\CompanyService;
use App\Model\SupplierAttachmentsModel;
use Illuminate\Support\Facades\Validator;
use App\Http\Services\SupplierPayTypeService;
class SupplierValidator
{
......@@ -35,9 +35,11 @@ class SupplierValidator
//新增的时候要先去检验下一体化的数据,如果是实体黑名单用户,那么就不允许新增
$regionType = $validateData['region'] == SupplierChannelModel::REGION_CN ? 1 : 2;
//还要校验提交上来的公司是否有合法信息
$unitedCompanyInfo = (new CompanyService())->getUnitedCompanyInfo($validateData['supplier_name'],
$unitedCompanyInfo = (new CompanyService())->getUnitedCompanyInfo(
$validateData['supplier_name'],
$validateData['tax_number'],
$regionType);
$regionType
);
$unitedInfo = $unitedCompanyInfo['united_company_info'];
if ($unitedInfo && $isAdd) {
if (isset($unitedCompanyInfo['is_entity']) && $unitedCompanyInfo['is_entity'] == 1) {
......@@ -126,6 +128,7 @@ class SupplierValidator
'us_ratio' => 'min:1',
'is_business_abnormal' => 'required',
'phone' => 'required',
'nation_id' => 'required',
];
//2022年6月30日(含)之前新建的供应商,在修改供应商信息时,可跳过“注册资金”这一必填项
if (!$isAdd) {
......@@ -151,8 +154,10 @@ class SupplierValidator
if (empty($validateData['supplier_type'])) {
return '请选择供应商类型';
}
if ($validateData['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY && in_array($validateData['supplier_name'],
config('field.SkipChangeSupplierTypeNames'))) {
if ($validateData['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY && in_array(
$validateData['supplier_name'],
config('field.SkipChangeSupplierTypeNames')
)) {
$errorMessageList[] = '该供应商是代购供应商,不能修改为临时供应商';
}
......@@ -169,10 +174,11 @@ class SupplierValidator
$errorMessageList[] = '附件中代理证的有效期为必填,请检查对应代理证的附件有效期';
}
}
} else {
$attachmentFields = SupplierAttachmentsModel::where('supplier_id',
$supplierId)->get()->pluck('field_name')->toArray();
$attachmentFields = SupplierAttachmentsModel::where(
'supplier_id',
$supplierId
)->get()->pluck('field_name')->toArray();
}
if (!$attachmentFields) {
......@@ -180,8 +186,10 @@ class SupplierValidator
} else {
$attachmentFields = array_unique($attachmentFields);
//fixed.php FileNameMapping 可以知道所有对应关系
if (!in_array('business_license', $attachmentFields)
&& $validateData['region'] == SupplierChannelModel::REGION_CN) {
if (
!in_array('business_license', $attachmentFields)
&& $validateData['region'] == SupplierChannelModel::REGION_CN
) {
$errorMessageList[] = '国内供应商必须上传营业执照';
}
......@@ -191,8 +199,10 @@ class SupplierValidator
}
}
if ($validateData['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_OFFICIAL && !in_array($validateData['supplier_group'],
[SupplierChannelModel::SUPPLIER_GROUP_ORIGINAL, SupplierChannelModel::SUPPLIER_GROUP_PROXY])) {
if ($validateData['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_OFFICIAL && !in_array(
$validateData['supplier_group'],
[SupplierChannelModel::SUPPLIER_GROUP_ORIGINAL, SupplierChannelModel::SUPPLIER_GROUP_PROXY]
)) {
if (!in_array('quality_assurance_agreement', $attachmentFields)) {
$errorMessageList[] = '供应商为正式供应商,品质保证协议必须上传 (代理商跟原厂类型除外) ';
}
......@@ -213,7 +223,6 @@ class SupplierValidator
}
//还有代理证的有效期为必填
if (!in_array('proxy_certificate', $attachmentFields)) {
}
}
......@@ -238,7 +247,6 @@ class SupplierValidator
}
}
}
}
......@@ -272,7 +280,6 @@ class SupplierValidator
}
}
}
}
......@@ -314,8 +321,10 @@ class SupplierValidator
$companyNameCount = 0;
if (empty($supplierId)) {
$count = SupplierChannelModel::where('supplier_name', $validateData['supplier_name'])->count();
$companyNameCount = SupplierChannelModel::where('register_company_name',
$validateData['register_company_name'])->where('register_company_name', '!=', '')->count();
$companyNameCount = SupplierChannelModel::where(
'register_company_name',
$validateData['register_company_name']
)->where('register_company_name', '!=', '')->count();
} else {
//对接一体化以后,名称不能修改了,所以直接为0
$count = 0;
......@@ -393,6 +402,7 @@ class SupplierValidator
'registered_capital.numeric' => '注册资金填纯数字即可,默认单位是万',
'is_business_abnormal.required' => '是否历史经营异常必选,请补充选择',
'sign_com_id.required' => '发生跨境交易时的合同签约公司 不能为空',
'nation_id.required' => '所在国家/地区 不能为空',
];
}
......
......@@ -90,5 +90,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
DataService::repairSupplierCpTime();
DataService::repairNationInternationalCode();
});
......@@ -10,4 +10,14 @@ class NationModel extends Model
protected $table='nation';
protected $primaryKey = 'nation_id';
public $timestamps = false;
public static function getNationList()
{
$natioList = self::all()->toArray();
$data = [];
foreach ($natioList as $item) {
$data[$item['nation_id']] = $item['name_cn'] . ' | ' . $item['international_code'];
}
return $data;
}
}
......@@ -60,5 +60,6 @@ return [
'sign_com_id' => '签约公司id',
'sign_com_name' => '签约公司名称',
'sku_optional_batch_text' => 'SKU可选批次',
'nation_id' => '国家/地区',
]
];
......@@ -33,6 +33,18 @@
form.on('radio(receipt_type)', function (data) {
g.receiptType = data.value;
if (data.value === '1') {
$('#bank_address_require_span').hide();
$('#nation_id').val('36');
$('#nation_id').attr('disabled', true);
$('#nation_id').addClass('layui-disabled');
form.render('select');
} else {
$('#nation_id').val('');
$('#nation_id').attr('disabled', false);
$('#nation_id').removeClass('layui-disabled');
form.render('select');
}
});
//图片上传
......
......@@ -8,19 +8,24 @@
let element = layui.element;
let xmSelect = layui.xmSelect;
form.on('radio(receipt_type)', function (data) {
form.on('radio(supplier_type)', function (data) {
if (data.value == 1) {
$('#swift_code_div').hide();
$('#nation_id_div').hide();
$('#account_name_label').text('账户名称 : ');
$('#account_name_require_span').hide();
$('#bank_address_require_span').hide();
$('#nation_id').val('36');
$('#nation_id').attr('disabled', true);
$('#nation_id').addClass('layui-disabled');
form.render('select');
} else {
$('#swift_code_div').show();
$('#nation_id_div').show();
$('#account_name_label').text('国外受益人 : ');
$('#account_name_require_span').show();
$('#bank_address_require_span').show();
$('#nation_id').attr('disabled', false);
$('#nation_id').removeClass('layui-disabled');
form.render('select');
}
});
......
......@@ -143,6 +143,16 @@
//如果选择区域为国内,那么成立时间disabled
//这里还有就是region有个对应公司id的映射关系,要自动切换对应的签约公司下拉
form.on('select(region)', function(data) {
if (data.value === '2') {
$('#nation_id').val('36');
} else if (data.value === '4') {
$('#nation_id').val('194');
} else if (data.value === '6') {
$('#nation_id').val('195');
}else{
$('#nation_id').val('');
}
form.render('select');
@if (empty($supplier))
let supplierNameObj = $('#supplier_name');
let taxNumberObj = $('#tax_number');
......
......@@ -34,7 +34,7 @@
{field: 'account_no', title: '<span class="require">* </span>银行账号', align: 'center', width: 130},
{field: 'account_name', title: '账户名称', align: 'center', width: 150},
{field: 'swift_code', title: 'Swift Code', align: 'center', width: 130},
// {field: 'international_code', title: '国际代码', align: 'center', width: 130},
// {field: 'nation_id', title: '国际代码', align: 'center', width: 130},
{
field: 'certificate',
title: '<span class="require">* </span>信息凭证',
......@@ -45,7 +45,7 @@
},
{field: 'account_adderss', title: '银行地址', align: 'center', width: 200},
{
field: 'nation_name', title: '银行国家', align: 'center', width: 100, templet: function (data) {
field: 'nation_name', title: '国家/地区', align: 'center', width: 100, templet: function (data) {
return data.nation ? data.nation.name_cn : '';
}
},
......
......@@ -38,16 +38,20 @@
<input type="hidden" name="apply_audit_reason" id="apply_audit_reason">
<div class="layui-form-item">
<div class="layui-col-md3">
<div class="layui-col-md2">
@inject('singleSelectPresenter','App\Presenters\SingleSelectPresenter')
{!! $singleSelectPresenter->render('supplier_type','供应商类别',!empty($supplier)?array_get($supplier,'supplier_type',0):'1',[1=>'正式',2=>'临时'],['require'=>true]) !!}
</div>
<div class="layui-col-md3">
<div class="layui-col-md4">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('region','所在区域 : ','',
config('fixed.Region'),['required'=>true,'width'=>'150px']) !!}
config('fixed.Region'),['required'=>true,'width'=>'120px']) !!}
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('nation_id','所在国家/地区 : ','',
$nationList,['required'=>true,'width'=>'120px','label_width'=>'110px']) !!}
</div>
<div class="layui-col-md6">
<div class="city-div" style="display: none">
<label class="layui-form-label">选择省市 : </label>
......@@ -344,9 +348,9 @@
</div>
</div>
<div class="layui-col-md4">
<div class="layui-form-item" id="nation_id_div" style="display: none">
<div class="layui-form-item" id="nation_id_div">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('nation_id','银行国家 : ',0,
{!! $statusPresenter->render('nation_id','国家/地区 : ',0,
$nationList,['required'=>true]) !!}
</div>
</div>
......@@ -368,7 +372,7 @@
value="">
</div>
</div>
<div class="layui-col-md4">
<div class="layui-col-md12">
<label class="layui-form-label">备注 : </label>
<div class="layui-input-block block-42">
<input type="text" name="remark" id="remark"
......
......@@ -69,9 +69,9 @@
value="{{$receipt['account_adderss'] or ''}}">
</div>
</div>
<div class="layui-form-item" id="nation_id_div" x-show="receiptType === '2'">
<div class="layui-form-item" id="nation_id_div">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('nation_id','银行国家 : ',isset($receipt['nation_id'])?$receipt['nation_id']:0,
{!! $statusPresenter->render('nation_id','国家/地区 : ',isset($receipt['nation_id'])?$receipt['nation_id']:0,
$nationList,['required'=>true]) !!}
</div>
<div class="layui-form-item" id="swift_code_div" x-show="receiptType === '2'">
......@@ -82,6 +82,7 @@
value="{{$receipt['swift_code'] or ''}}">
</div>
</div>
<br>
<div class="layui-form-item">
<label class="layui-form-label">
<span class="require">*</span>供应商银行信息凭证:
......
......@@ -32,14 +32,16 @@
?>
<div class="layui-form-item">
<div class="layui-col-md3">
<div class="layui-col-md2">
@inject('singleSelectPresenter','App\Presenters\SingleSelectPresenter')
{!! $singleSelectPresenter->render('supplier_type','供应商类别',!empty($supplier)?array_get($supplier,'supplier_type',0):'1',$supplierType,$option) !!}
</div>
<div class="layui-col-md3">
<div class="layui-col-md4">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('region','所在区域 : ',$supplier['region'],
config('fixed.Region'),['required'=>true,'width'=>'150px']) !!}
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('nation_id','所在国家/地区: ',!empty($supplier)?$supplier['nation_id']:'',$nationList,['required'=>true,'width'=>'110px','label_width'=>'90px']) !!}
</div>
<div class="layui-col-md6">
<div class="city-div" style="display: none">
......
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