Commit 018cb350 by 杨树贤

1.银行信息添加国家选择以及同步到金蝶要拼接上国家

2.银行账号格式规范
parent ed2a10a4
......@@ -148,6 +148,7 @@ class SupplierApiController extends Controller
'account_adderss',
'certificate',
'swift_code',
'nation_id',
]);
$channel = $request->only($channelMap);
......
......@@ -29,14 +29,14 @@ class SupplierReceiptApiController extends Controller
$limit = $request->get('limit', 10);
$model = new SupplierReceiptModel();
$model->where('supplier_id', $supplierId)->paginate();
$list = $model->where('supplier_id', $supplierId)->orderBy('receipt_id', 'desc')
$list = $model->with(['nation'])->where('supplier_id', $supplierId)->orderBy('receipt_id', 'desc')
->paginate($limit)->toArray();
$transformer = new ReceiptTransformer();
$list['data'] = $transformer->transformList($list['data']);
$this->response(0, 'ok', $list['data'], $list['total']);
}
//获取供应商信息变更记录
//新增银行信息
public function AddSupplierReceipt($request)
{
//先去表单验证
......@@ -61,11 +61,13 @@ class SupplierReceiptApiController extends Controller
'certificate',
'account_name',
'remark',
'nation_id',
//'international_code'
]);
$receipt['account_adderss'] = empty($receipt['account_adderss']) ? ' ' : $receipt['account_adderss'];
if ($receipt['receipt_type'] == 1) {
$receipt['swift_code'] = '';
$receipt['nation_id'] = 0;
}
$receiptId = $request->get('receipt_id');
$supplierId = $request->get('supplier_id');
......
......@@ -16,6 +16,7 @@ use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\SupplierTransformer;
use App\Model\IntracodeModel;
use App\Model\LogModel;
use App\Model\NationModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Illuminate\Http\Request;
......@@ -172,6 +173,7 @@ class SupplierController extends Controller
//省市区数据放到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'] = [];
//编辑
......
......@@ -8,6 +8,7 @@ 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;
use Illuminate\Http\Request;
......@@ -46,6 +47,7 @@ class SupplierReceiptController extends Controller
public function AddSupplierReceipt($request)
{
$this->data['title'] = '添加供应商银行';
$this->data['nationList'] = NationModel::pluck('name_cn','nation_id')->toArray();
return $this->view('添加供应商银行');
}
......@@ -57,11 +59,11 @@ class SupplierReceiptController extends Controller
$model = new SupplierReceiptModel();
$this->data['receipt'] = $model->where('receipt_id', $receiptId)->first()->toArray();
}
$this->data['nationList'] = NationModel::pluck('name_cn','nation_id')->toArray();
$this->data['title'] = '修改供应商银行';
$this->data['view'] = 'AddSupplierReceipt';
return $this->view('修改供应商银行');
}
}
......@@ -13,7 +13,7 @@ class SupplierReceiptService
{
//判断字符串是否自由数字、英文字母、字符“-”和“()”
public static function checkAccountNo($str) {
return preg_match("/^[0-9a-zA-Z\-\(\)]*$/", $str) === 1;
return preg_match("/^[0-9a-zA-Z\-\(\) ]*$/", $str) === 1;
}
//字符串保留数字、英文字母、字符“-”和“()”
......
......@@ -66,7 +66,6 @@ class SupplierService
$supplierTransformer = new SupplierTransformer();
//先处理下数据
$channel = $supplierTransformer->transformPostData($channel);
$logService = new LogService();
$model = new SupplierChannelModel();
......
......@@ -91,18 +91,19 @@ class SyncSupplierService
->where('is_type', 0)->where('group_code', '!=', '')
->pluck('supplier_id')->toArray();
//银行信息
$receipts = SupplierReceiptModel::whereIn('supplier_id', $supplierIds)->get()->toArray();
$receipts = SupplierReceiptModel::with(['nation'])->whereIn('supplier_id', $supplierIds)->get()->toArray();
//->where('bank_name', '!=', '')->where('account_no', '!=', '')->get()->toArray();
if (!empty($receipts)) {
$message['bankinfo'] = [];
foreach ($receipts as $receipt) {
$address = !empty($receipt['nation']['name_cn']) ? $receipt['nation']['name_cn'] . $receipt['account_adderss'] : $receipt['account_adderss'];
$message['bankinfo'][] = [
"bank" => $receipt['bank_adderss'],
'bankaccount' => $receipt['account_no'],
'supplier' => $receipt['bank_name'],
'swiftCode' => $receipt['swift_code'],
'beneficiary' => $receipt['account_name'],
'bankAddress' => $receipt['account_adderss'],
'bankAddress' => $address,
'infoEvidence' => $receipt['certificate'],
'recid' => $receipt['receipt_id'],
//'bankaccount' => $receipt['international_code'],
......
......@@ -285,7 +285,8 @@ class SupplierTransformer
public function transformPostData($channel)
{
$channel['supplier_name'] = trim($channel['supplier_name']);
$channel['supplier_name'] = replaceSpace($channel['supplier_name']);
$channel['supplier_name'] = replaceSpecialSpace($channel['supplier_name']);
$channel['supplier_name'] = deleteExtraSpace($channel['supplier_name']);
if (!empty($channel['stockup_type'])) {
$stockupType = array_keys($channel['stockup_type']);
$stockupType = !empty($stockupType) ? implode(",", $stockupType) : '';
......
......@@ -18,7 +18,7 @@ class ReceiptValidator
$rules = [
"bank_name" => "required",
"bank_adderss" => "required",
"account_no" => "required",
"account_no" => ['required', 'regex:/^[0-9]+$/'],
//"account_no" => "required|regex:/^[0-9\-]+$/",
"receipt_type" => 'required',
"certificate" => "required",
......@@ -28,19 +28,20 @@ class ReceiptValidator
$rules["account_adderss"] = 'required';
$rules["account_name"] = 'required';
$rules["bank_adderss"] = 'required';
$rules["nation_id"] = 'required';
$rules['account_no'] = ['required'];
//$rules["international_code"] = 'required';
}
$messages = $this->messages();
$validator = Validator::make($receipt, $rules, $messages);
$otherErrors = [];
if (!SupplierReceiptService::checkAccountNo($receipt['account_no'])) {
if (!SupplierReceiptService::checkAccountNo($receipt['account_no']) && $receipt['receipt_type'] == 2) {
if ($returnAllError) {
$otherErrors[] = '银行账号仅支持输入数字、英文字母、符号“-”“()”';
$otherErrors[] = '银行账号仅支持输入数字、英文字母、符号 - () 、空格';
return $otherErrors;
}else{
return '银行账号仅支持输入数字、英文字母、符号“-”“()”';
} else {
return '银行账号仅支持输入数字、英文字母、符号 - () 、空格';
}
}
......@@ -67,9 +68,11 @@ class ReceiptValidator
'bank_adderss.required' => '开户行 不能为空',
'swift_code.required' => '银行国际代码 Swift Code 不能为空',
'account_no.required' => '银行账号 不能为空',
'account_no.regex' => '国内银行账号仅支持输入数字且中间不能有空格',
'account_name.required' => '账户名称 不能为空',
'certificate.required' => '银行信息凭证 不能为空',
'account_adderss.required' => '银行地址 不能为空',
'nation_id.required' => '银行国家 不能为空',
//'international_code.required' => '国际代码 不能为空',
];
}
......
......@@ -320,7 +320,7 @@ function getSpuSkuDb($id)
}
//去除特殊空格
function replaceSpace($str)
function replaceSpecialSpace($str)
{
$str = str_replace(" ", " ", $str);
//头尾的空格去掉
......@@ -332,3 +332,14 @@ function isDevEnvironment()
{
return config('perm.perm.menuId') == 16;
}
//去除多余空格
function deleteExtraSpace($inputString)
{
// 使用正则表达式替换多个空格为一个空格
$outputString = preg_replace('/\s+/', ' ', $inputString);
// 输出结果
return $outputString; // 输出: "This is a string with several spaces."
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class NationModel extends Model
{
protected $connection = 'liexin';
protected $table='nation';
protected $primaryKey = 'nation_id';
public $timestamps = false;
}
......@@ -7,52 +7,62 @@ use request;
class SupplierReceiptModel extends Model
{
protected $connection='web';
protected $table='supplier_receipt';
protected $connection = 'web';
protected $table = 'supplier_receipt';
public $timestamps = false;
public function AddInfo($SupplierID='',$data=''){
if(empty($SupplierID) || empty($data) || !is_array($data)) return false;
foreach ($data as $k=>$v){
public function nation()
{
return $this->hasOne(NationModel::class, 'nation_id', 'nation_id');
}
public function AddInfo($SupplierID = '', $data = '')
{
if (empty($SupplierID) || empty($data) || !is_array($data)) return false;
foreach ($data as $k => $v) {
unset($v['receipt_id']);
$v['supplier_id'] = $SupplierID;
$v['receipt_type'] = $k;
$result=$this->insert($v);
$result = $this->insert($v);
}
return $result;
}
public function SaveInfo($SupplierID='',$data=''){
if(!is_array($data) || (empty($data[1]['receipt_id']) && empty($data[2]['receipt_id']))) return false;
if(isset($data[1]['receipt_id']) && !empty($data[1]['receipt_id'])){
public function SaveInfo($SupplierID = '', $data = '')
{
if (!is_array($data) || (empty($data[1]['receipt_id']) && empty($data[2]['receipt_id']))) return false;
if (isset($data[1]['receipt_id']) && !empty($data[1]['receipt_id'])) {
$data[1]['supplier_id'] = $SupplierID;
$receipt_id = $data[1]['receipt_id'];
unset($data[1]['receipt_id']);
$res = $this->where('receipt_id','=',$receipt_id)->update($data[1]);
$res = $this->where('receipt_id', '=', $receipt_id)->update($data[1]);
}
if(isset($data[2]['receipt_id']) && !empty($data[2]['receipt_id'])){
if (isset($data[2]['receipt_id']) && !empty($data[2]['receipt_id'])) {
$data[2]['supplier_id'] = $SupplierID;
$receipt_id = $data[2]['receipt_id'];
unset($data[2]['receipt_id']);
$res = $this->where('receipt_id','=',$receipt_id)->update($data[2]);
}else{
$res = $this->where('receipt_id', '=', $receipt_id)->update($data[2]);
} else {
$data[2]['supplier_id'] = $SupplierID;
$data[2]['receipt_type'] = 2;
$result=$this->insert($data[2]);
$result = $this->insert($data[2]);
}
return $res;
}
public function ReceiptInfo($SupplierID=''){
$collert=Request::only('supplier_id');
$collert=TrimX($collert,true,['supplier_id']);
empty($collert) && $collert['supplier_id']=$SupplierID;
if(empty($collert['supplier_id'])) return false;
$info=$this->where('supplier_id','=',$collert['supplier_id'])->get();
if(!$info) return false;
public function ReceiptInfo($SupplierID = '')
{
$collert = Request::only('supplier_id');
$collert = TrimX($collert, true, ['supplier_id']);
empty($collert) && $collert['supplier_id'] = $SupplierID;
if (empty($collert['supplier_id'])) return false;
$info = $this->where('supplier_id', '=', $collert['supplier_id'])->get();
if (!$info) return false;
$res = $info->toArray();
$data = array();
foreach ($res as $k=>$v){
foreach ($res as $k => $v) {
$data[$v['receipt_type']] = $v;
}
return $data;
......
......@@ -11,11 +11,13 @@
form.on('radio(receipt_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();
} else {
$('#swift_code_div').show();
$('#nation_id_div').show();
$('#account_name_label').text('国外受益人 : ');
$('#account_name_require_span').show();
$('#bank_address_require_span').show();
......
......@@ -38,12 +38,17 @@
{
field: 'certificate',
title: '<span class="require">* </span>信息凭证',
width: 200, align: 'center',
width: 150, align: 'center',
templet: function (data) {
return "<a style='color: blue' href='" + data.certificate + "' target='_blank'>" + data.certificate + "</a>";
}
},
{field: 'account_adderss', title: '银行地址', align: 'center', width: 200},
{
field: 'nation_name', title: '银行国家', align: 'center', width: 100, templet: function (data) {
return data.nation ? data.nation.name_cn : '';
}
},
{field: 'remark', title: '备注', align: 'center', width: 200},
]],
id: 'receiptList',
......@@ -55,7 +60,7 @@
layer.open({
type: 2,
content: '/supplier_receipt/AddSupplierReceipt?view=iframe&supplier_id=' + supplierId,
area: ['50%', '70%'],
area: ['50%', '90%'],
title: '新增银行',
end: function () {
table.reload('receiptList');
......@@ -75,7 +80,7 @@
layer.open({
type: 2,
content: '/supplier_receipt/UpdateSupplierReceipt?view=iframe&supplier_id=' + supplierId + '&receipt_id=' + receiptId,
area: ['50%', '70%'],
area: ['50%', '90%'],
title: '修改银行',
end: function () {
table.reload('receiptList');
......
......@@ -319,7 +319,9 @@
</div>
</div>
<div class="layui-col-md4">
<label class="layui-form-label"><span class="require" id="account_name_require_span" style="display: none">*</span><span id="account_name_label">账户名称</span> </label>
<label class="layui-form-label"><span class="require" id="account_name_require_span"
style="display: none">*</span><span id="account_name_label">账户名称</span>
</label>
<div class="layui-input-block block-42">
<input type="text" name="account_name" id="account_name"
placeholder="请输入账户名称" class="layui-input"
......@@ -327,7 +329,8 @@
</div>
</div>
<div class="layui-col-md4">
<label class="layui-form-label"><span class="require" style="display: none" id="bank_address_require_span" >*</span>银行地址 : </label>
<label class="layui-form-label"><span class="require" style="display: none"
id="bank_address_require_span">*</span>银行地址 : </label>
<div class="layui-input-block block-42">
<input type="text" name="account_adderss" id="account_adderss"
placeholder="请输入银行具体地址或银行所在国家" class="layui-input"
......@@ -335,19 +338,10 @@
</div>
</div>
<div class="layui-col-md4">
<label class="layui-form-label">
<span class="require">*</span>银行凭证:
</label>
<div class="layui-input-block">
<input type="hidden" name="certificate" id="certificate"
value="">
<button type="button" class="layui-btn upload-img layui-btn-sm" preview="preview"
data-obj="certificate">
<i class="layui-icon">&#xe67c;</i>上传文件
</button>
<a target="_blank" id="certificate_url"
href=""></a>
<div class="layui-form-item" id="nation_id_div" style="display: none">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('nation_id','银行国家 : ',0,
$nationList,['required'=>true]) !!}
</div>
</div>
<div class="layui-col-md4">
......@@ -368,6 +362,23 @@
value="">
</div>
</div>
<div class="layui-col-md12">
<label class="layui-form-label">
<span class="require">*</span>银行凭证:
</label>
<div class="layui-input-block">
<input type="hidden" name="certificate" id="certificate"
value="">
<button type="button" class="layui-btn upload-img layui-btn-sm" preview="preview"
data-obj="certificate">
<i class="layui-icon">&#xe67c;</i>上传文件
</button>
<a target="_blank" id="certificate_url"
href=""></a>
</div>
</div>
</div>
<blockquote class="layui-elem-quote layui-text">
<b>联系人</b>
......
......@@ -69,16 +69,11 @@
value="{{$receipt['account_adderss'] or ''}}">
</div>
</div>
{{-- <div class="layui-form-item" x-show="receiptType === '2'">--}}
{{-- <label class="layui-form-label">--}}
{{-- <span style="color: red">* </span>--}}
{{-- 国际代码 : </label>--}}
{{-- <div class="layui-input-block block-42">--}}
{{-- <input type="text" name="international_code" id="international_code"--}}
{{-- placeholder="请输入银行国际代码" class="layui-input"--}}
{{-- value="{{$receipt['international_code'] or ''}}">--}}
{{-- </div>--}}
{{-- </div>--}}
<div class="layui-form-item" id="nation_id_div" x-show="receiptType === '2'">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $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'">
<label class="layui-form-label"><span class="require">*</span>Swift Code : </label>
<div class="layui-input-block block-42">
......@@ -100,8 +95,6 @@
</button>
<a target="_blank" id="certificate_url"
href="{{$receipt['certificate'] or ''}}">{{$receipt['certificate'] or ''}}</a>
{{-- <img @if(!empty($receipt['certificate'])) src="{{$receipt['certificate'] or ''}}"--}}
{{-- @endif class="layui-upload-img" width="50px" height="50px" id="preview">--}}
</div>
</div>
<div class="layui-form-item">
......
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