Commit 126ca0c6 by 杨树贤

临时暂存

parent 98f56bd5
......@@ -40,6 +40,7 @@ class SupplierApiController extends Controller
'legal_representative',
'established_time',
'trading_method',
'phone',
//省市
'province_city',
......@@ -173,6 +174,7 @@ class SupplierApiController extends Controller
}
$channelMap = array_merge($this->channelMap, config('field.AttachmentFields'));
$channel = $request->only($channelMap);
dd($channel);
$service = new SupplierService();
$result = $service->saveSupplier($channel);
if (!$result) {
......@@ -285,6 +287,7 @@ class SupplierApiController extends Controller
$supplierName = trim($request->get('supplier_name'));
$taxNumber = $request->get('tax_number');
$supplierId = $request->get('supplier_id');
$region = $request->get('region');
$model = new SupplierChannelModel();
//如果是编辑操作,则要忽略非当前
......@@ -315,11 +318,11 @@ class SupplierApiController extends Controller
// }
}
}
$regionType = $region == 2 ? 1 : 2;
//还要去请求天眼查获取资料
$company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber);
$company = (new CompanyService())->getCompanyInfo($supplierName, $taxNumber,$regionType);
if (!$company) {
$this->response(-1, '公司未进行工商注册,请修改后重新提交');
$this->response(-2, '公司未进行工商注册,请修改后重新提交');
}
$this->response(0, '供应商名称合理', $company);
}
......
......@@ -12,11 +12,11 @@ use Illuminate\Support\Facades\DB;
class CompanyService
{
public function getCompanyInfo($supplierName, $taxNumber)
public function getCompanyInfo($supplierName, $taxNumber,$regionType = 1)
{
$params = [
'keyword' => $supplierName ?: $taxNumber,
'region' => 1,
'region' => $regionType,
'select_type' => 1,
];
$url = config('website.InternalApiDomain') . '/companyInfo';
......@@ -27,10 +27,10 @@ class CompanyService
$companyInfo = array_get($result['data'], 0);
$company = [
'supplier_name' => $companyInfo['com_name'],
'registered_capital' => $companyInfo['registered_capital'],
'registered_capital' => (int)$companyInfo['registered_capital'],
'supplier_address' => $companyInfo['com_address'],
'tax_number' => $companyInfo['tyc_info']['taxNumber'],
'phone' => $companyInfo['tyc_info']['phoneNumber'],
'tax_number' => $companyInfo['tyc_info']['tax_number'],
'phone' => $companyInfo['tyc_info']['phone_number'],
];
}
return $company;
......
......@@ -64,11 +64,6 @@ class SupplierAuditService
if ($result) {
//如果状态是复审
if ($supplier['status'] == SupplierChannelModel::STATUS_NEED_REVIEW) {
// if ($status == SupplierChannelModel::STATUS_PASSED) {
// SupplierChannelModel::where('supplier_id', $supplierId)->update([
// 'level' => 'E',
// ]);
// }
$auditStatus = $status == SupplierChannelModel::STATUS_PASSED ? '复审通过' : '复审不通过,原因是 : ' . $rejectReason;
$action = '复审供应商';
} else {
......@@ -84,6 +79,8 @@ class SupplierAuditService
//发送队列消息同步到金蝶
$service = new SyncSupplierService();
$service->syncSupplierToErp($supplierId);
//同步给一体化系统
(new SyncSupplierService())->syncSupplierToUnited($supplierId);
}
return $result;
}
......
......@@ -48,8 +48,11 @@ class SupplierService
//走事务
$supplierId = DB::connection('web')->transaction(function () use ($channel, $model, $oldSupplier) {
$tagService = new SupplierTagService();
//是否直接申请审核
$isDirectApply = request()->get('direct_apply');
$tagService = new SupplierTagService();
//获取附加税数据
$extraFax = [
'supplier_id' => $channel['supplier_id'],
......@@ -121,7 +124,7 @@ class SupplierService
}, $channel);
//默认是待审核
//判断是否是直接添加并且申请审核
if (request()->get('direct_apply')) {
if ($isDirectApply) {
$channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
} else {
$channel['status'] = SupplierChannelModel::STATUS_PENDING;
......@@ -179,7 +182,9 @@ class SupplierService
$supplierAddressService->saveShippingAddress($supplierId, $shippingAddress);
} else {
//这里的是更新供应商的操作
/**这里的是更新供应商的操作**/
$supplierId = $this->newSupplierId = $channel['supplier_id'];
//要做进一步判断,部分字段修改不需要审核
......@@ -242,14 +247,13 @@ class SupplierService
$oldSystemTags);
$tagService->saveTags($supplierId, SupplierTagService::TAG_TYPE_CUSTOMER, $channel['customer_tags'],
$oldCustomerTags);
return $supplierId;
}
//重新生成外部显示的编码
$this->generateSupplierSn($supplierId, $channel['supplier_group']);
//保存和搜索相关的标签情况
$supplierSearchTagService = new SupplierSearchTagService();
$supplierSearchTagService->saveSupplierSearchTags($supplierId);
return $supplierId;
});
//保存日志
......
......@@ -8,6 +8,7 @@ use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Model\SupplierSyncModel;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
......@@ -127,7 +128,7 @@ class SyncSupplierService
'company_type' => 2,
'company_name' => $supplier['supplier_name'],
'company_tax_no' => $supplier['tax_number'],
'init_nature' => $supplier['supplier_group'],
'init_nature' => Arr::get(config('fixed.SupplierGroup'), $supplier['supplier_group']),
'region' => $supplier['region'] == 2 ? 1 : 2,
'pi_file_url' => $fileUrl ?: '',
];
......
......@@ -3,6 +3,7 @@
namespace App\Http\Validators;
use App\Http\Services\CompanyService;
use App\Http\Services\SupplierPayTypeService;
use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel;
......@@ -68,6 +69,7 @@ class SupplierValidator
'cn_ratio' => 'min:1',
'us_ratio' => 'min:1',
'is_business_abnormal' => 'required',
'phone' => 'required',
];
$contactRuler = [
'supplier_consignee' => 'required|max:50',
......@@ -245,21 +247,21 @@ class SupplierValidator
if (!empty($supplierId)) {
//还要去判断当前提交人是否存在与其关联的联系人没有完善
$codeId = request()->user->codeId;
$notCompleteContacts = SupplierContactModel::where('supplier_id', $supplierId)
->where('can_check_uids', $codeId)
->where(function ($q) {
$q->where('supplier_consignee', '')
->orWhere('supplier_position', '')
->orWhere('supplier_email', '')
->orWhere('supplier_mobile', '')
->orWhere('supplier_telephone', '');
})->get();
$notCompleteContacts = !empty($notCompleteContacts) ? $notCompleteContacts->toArray() : [];
$notCompleteContacts = (new SupplierContactModel())->getNotCompletedContacts($supplierId, $codeId);
if ($notCompleteContacts) {
$errorMessageList[] = "存在和你相关的联系人没有完善,请先去完善相关联系人";
}
}
if (!checkPerm('IgnoreCompanyCheck')) {
$regionType = $validateData['region'] == 2 ? 1 : 2;
//还要校验提交上来的公司是否有合法信息
$companyInfo = (new CompanyService())->getCompanyInfo($validateData['supplier_name'],
$validateData['tax_number'],
$regionType);
if (empty($companyInfo)) {
$errorMessageList[] = '公司未进行工商注册,请修改后重新提交';
}
}
return implode('|', $errorMessageList);
}
......@@ -288,6 +290,7 @@ class SupplierValidator
'supplier_consignee.required' => '联系方式的联系人 不能为空',
'supplier_consignee.max' => '联系方式的联系人不能超过50个字符',
'supplier_position.required' => '联系方式的职称 不能为空',
'phone.required' => '公司电话 不能为空',
'supplier_position.max' => '联系方式的职称不能超过30个字符',
'supplier_telephone.required' => '联系方式的座机号 不能为空',
'supplier_mobile.required' => '联系方式的手机号 不能为空',
......
......@@ -60,5 +60,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\SyncSupplierService())->syncSupplierToUnited(10);
(new \App\Http\Services\SyncSupplierService())->syncSupplierToUnited(12421);
});
......@@ -7,26 +7,33 @@ use Request;
class SupplierContactModel extends Model
{
protected $connection='web';
protected $table='supplier_contact';
protected $connection = 'web';
protected $table = 'supplier_contact';
public $timestamps = false;
public function AddInfo($SupplierID='',$data=''){
if(empty($SupplierID) || empty($data) || !is_array($data)) return false;
public function AddInfo($SupplierID = '', $data = '')
{
if (empty($SupplierID) || empty($data) || !is_array($data)) {
return false;
}
$Add = array();
foreach ($data as $k=>$v){
foreach($v as $kk=>$vv){
foreach ($data as $k => $v) {
foreach ($v as $kk => $vv) {
$Add[$kk][$k] = $vv;
$Add[$kk]['supplier_id'] = $SupplierID;
}
}
foreach($Add as $v){
foreach ($Add as $v) {
$this->insert($v);
}
return true;
}
public function AddContactInfo($data='', $is_update = false){
if(empty($data) || !is_array($data)) return false;
public function AddContactInfo($data = '', $is_update = false)
{
if (empty($data) || !is_array($data)) {
return false;
}
if ($is_update) { // 更新
$supplier_id = $data['supplier_id'];
unset($data['supplier_id']);
......@@ -36,24 +43,43 @@ class SupplierContactModel extends Model
}
}
public function SaveInfo($SupplierID='',$data=''){
if($SupplierID<=0) return false;
public function SaveInfo($SupplierID = '', $data = '')
{
if ($SupplierID <= 0) {
return false;
}
$this->where('supplier_id', '=', $SupplierID)->delete();
return $this->AddInfo($SupplierID,$data);
return $this->AddInfo($SupplierID, $data);
}
public function ContactInfo($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;
$info=$info->toArray();
// $Arr=[];
// foreach ($info as $k=>$v){
// $Arr[$v['address_type']]=$v;
// }
public function ContactInfo($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;
}
$info = $info->toArray();
return $info;
}
//获取未完整的联系方式
public function getNotCompletedContacts($supplierId, $codeId)
{
$notCompleteContacts = SupplierContactModel::where('supplier_id', $supplierId)
->where('can_check_uids', $codeId)
->where(function ($q) {
$q->where('supplier_consignee', '')
->orWhere('supplier_position', '')
->orWhere('supplier_email', '')
->orWhere('supplier_mobile', '')
->orWhere('supplier_telephone', '');
})->get();
return !empty($notCompleteContacts) ? $notCompleteContacts->toArray() : [];
}
}
......@@ -77,3 +77,11 @@ function ajax(url, data) {
layer.closeAll();
return result;
}
function inArray(needle, haystack) {
var length = haystack.length;
for (var i = 0; i < length; i++) {
if (haystack[i] == needle) return true;
}
return false;
}
......@@ -63,7 +63,7 @@
form.on('submit(addSupplier)', function (data) {
admin.showLoading({
type: 2,
type: 3,
});
let file_name = [];
let file_url = [];
......@@ -95,6 +95,7 @@
location.href = "/supplier/SupplierList"
}, 1000);
} else {
admin.removeLoading();
layer.msg(res.err_msg, {icon: 5});
}
}
......@@ -128,6 +129,7 @@
data.field.validity_type = validity_type;
data.field.validity_period = validity_period;
data.field.apply_audit_reason = $('#apply_audit_reason').val();
if (data.field.supplier_type === '2') {
layer.open({
type: 1,
......@@ -144,7 +146,9 @@
},
});
} else {
layer.confirm('确定直接申请审核吗?确定后会直接进入审核中的状态,审核完成前无法进行二次修改', function (index) {
let msg = '确定直接申请审核吗?确定后会直接进入审核中的状态,审核完成前无法进行二次修改';
//未上传品质保证协议(代理商则提示为“未上传代理证”),是否需要切换为临时供应商?
layer.confirm(msg, function (index) {
addSupplier(data);
});
}
......@@ -178,5 +182,27 @@
}
}
}
function attachmentsUploadedTips(){
let msg = '';
//已经上传品质保证协议(代理商则提示为“已经上传代理证”),是否切换为正式供应商?
if (data.field.supplier_type === 2) {
//如果已经上传品质保证协议,并且供应商性质不是代理商(代理商要代理证)
if (inArray('quality_assurance_agreement', data.field.field_name) && data.field.supplier_group !== 1) {
msg = '已经上传品质保证协议,是否切换为正式供应商?'
}
if (inArray('proxy_certificate', data.field.field_name) && data.field.supplier_group === 1) {
msg = '该供应商为代理供应商,已经上传代理证,是否切换为正式供应商?'
}
} else {
if (inArray('quality_assurance_agreement', data.field.field_name) && data.field.supplier_group !== 1) {
msg = '未上传品质保证协议,是否切换为临时供应商?'
}
if (inArray('proxy_certificate', data.field.field_name) && data.field.supplier_group === 1) {
msg = '该供应商为代理供应商,但是未上传代理证,是否切换为临时供应商?'
}
}
}
});
</script>
\ No newline at end of file
......@@ -65,6 +65,9 @@
});
function updateSupplier(data) {
admin.showLoading({
type: 3,
});
let res = ajax('/api/supplier/UpdateSupplier', data.field);
if (res.err_code === 0) {
admin.putTempData("needFreshList", 1)
......@@ -79,7 +82,7 @@
});
layer.msg(msg, {icon: 5})
}
admin.removeLoading();
}
});
</script>
\ No newline at end of file
......@@ -7,6 +7,9 @@
let element = layui.element;
let xmSelect = layui.xmSelect;
//这里有个权限,是可以跳过公司信息审核的
let ignoreCompanyCheck = {{checkPerm('IgnoreCompanyCheck') ? 1:0}};
layDate.render({
elem: '#established_time'
, type: 'month'
......@@ -18,19 +21,30 @@
$("#supplier_name").blur(function () {
const supplier_name = $(this).val();
const supplier_id = supplierId;
const region = $('#region').val();
const taxNumber = $('#tax_number').val();
$('#supplier_check_tip').remove();
let url = '/api/supplier/CheckSupplierName?supplier_name=' + supplier_name + '&supplier_id=' + supplier_id + '&tax_number=' + taxNumber;
let url = '/api/supplier/CheckSupplierName?supplier_name=' + supplier_name + '&supplier_id=' + supplier_id + '&tax_number=' + taxNumber + '&region=' + region;
let res = ajax(url);
if (!res) {
layer.msg('网络错误,请重试', {icon: 5});
} else {
if (supplier_name !== '') {
if (res.err_code === -1) {
layer.msg(res.err_msg, {icon: 5});
$(this).after("<div id='supplier_check_tip' style='margin-top: 5px'>" +
"<p style='color: red;'>" + res.err_msg + "</p></div>");
$('#supplier_name').prop('disabled', false);
if (res.err_code !== 0) {
//当code=-2的时候,是公司信息校验有问题,但是如果有跳过检查权限,那么就什么都不处理
if (res.err_code === -2) {
if (!ignoreCompanyCheck) {
layer.msg(res.err_msg, {icon: 5});
$(this).after("<div id='supplier_check_tip' style='margin-top: 5px'>" +
"<p style='color: red;'>" + res.err_msg + "</p></div>");
$('#supplier_name').prop('disabled', false);
}
} else {
layer.msg(res.err_msg, {icon: 5});
$(this).after("<div id='supplier_check_tip' style='margin-top: 5px'>" +
"<p style='color: red;'>" + res.err_msg + "</p></div>");
$('#supplier_name').prop('disabled', false);
}
} else if (res.err_code === 0) {
//如果供应商没有问题,就要去自动填补部分资料
let companyInfo = res.data;
......@@ -45,17 +59,6 @@
}
});
//监听币种变化,人民币才显示公司税号
form.on('select(currency)', function (data) {
if (data.value === '1') {
$('#tax_number_div').show();
form.render('select');
} else {
$('#tax_number_div').hide();
form.render('select');
}
});
@if(!empty($supplier))
@if($supplier['region']==2)
$('.city-div').show();
......@@ -254,9 +257,13 @@
layer.msg('校验公司信息通过,自动补全相关数据', {icon: 6})
} else {
admin.btnLoading('#recheck_company_info', false);
$('#supplier_name').after("<div id='supplier_check_tip' style='margin-top: 10px'>" +
"<p style='color: red;'>公司未进行工商注册,请修改后重新提交</p></div>");
layer.msg('公司未进行工商注册,请修改后重新提交', {icon: 5})
if (ignoreCompanyCheck) {
layer.msg('公司未进行工商注册')
} else {
$('#supplier_name').after("<div id='supplier_check_tip' style='margin-top: 5px'>" +
"<p style='color: red;'>公司未进行工商注册,请修改后重新提交</p></div>");
layer.msg('公司未进行工商注册,请修改后重新提交', {icon: 5})
}
}
}
});
......
......@@ -231,7 +231,6 @@
@include('web.supplier.SkuRuler')
</div>
</div>
</div>
</div>
@include('web.supplier.ApplyAuditReason')
......
......@@ -26,7 +26,7 @@
}
//临时类型的供应商,不显示待转正选项
if ($supplier['supplier_type'] == 2) {
if ($supplier['supplier_type'] == 2 || $supplier['is_type'] == 0) {
unset($supplierType[3]);
}
?>
......@@ -55,9 +55,10 @@
<div class="layui-input-block">
<input type="text" name="supplier_name" id="supplier_name"
placeholder="请输入供应商名称" class="layui-input @if ($supplier['sync_united_status']==1)
layui-disabled
@endif"
value="{{$supplier['supplier_name'] or ''}}" @if ($supplier['sync_united_status']==1) disabled @endif>
layui-disabled
@endif"
value="{{$supplier['supplier_name'] or ''}}"
@if ($supplier['sync_united_status']==1) disabled @endif>
</div>
</div>
<div class="layui-col-md5">
......@@ -139,8 +140,6 @@
</div>
@endif
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-row">
<div class="layui-col-md3">
......
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