Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
52f32859
authored
Jun 24, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
接收广播
parent
6c835da4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
8 deletions
app/Http/Services/CompanyService.php
app/Http/Services/SupplierAddressService.php
app/Http/Services/SupplierService.php
app/Http/Services/CompanyService.php
View file @
52f32859
...
...
@@ -5,6 +5,9 @@ namespace App\Http\Services;
//后台用户相关信息服务
use
App\Model\IntracodeModel
;
use
App\Model\SupplierAddressModel
;
use
App\Model\SupplierAttachmentsModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\UserDepartmentModel
;
use
App\Model\UserInfoModel
;
use
Illuminate\Support\Facades\DB
;
...
...
@@ -101,6 +104,72 @@ class CompanyService
return
$result
[
'data'
][
'result'
];
}
\Log
::
error
(
json_encode
(
$result
));
return
'一体化校验实体名单失败,请联系管理员'
;
}
//单独供应商校验名称和地址
public
function
checkSupplierCompanyAndAddress
(
$supplierId
)
{
$supplier
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
select
([
'supplier_id'
,
'supplier_name'
,
'supplier_name_en'
,
'supplier_address'
,
'create_uid'
,
'create_name'
,
])
->
first
()
->
toArray
();
$supplierAddressList
=
SupplierAddressModel
::
where
(
'supplier_id'
,
$supplierId
)
->
get
()
->
toArray
();
$businessLicense
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'field_name'
,
'business_license'
)
->
value
(
'file_url'
);
$addressData
=
[];
$addressData
[]
=
[
'source_id'
=>
$supplierId
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'供应商地址'
,
'address'
=>
$supplier
[
'supplier_address'
]
];
foreach
(
$supplierAddressList
as
$supplierAddress
)
{
if
(
$supplierAddress
[
'address_type'
]
==
1
)
{
$address
=
[
'source_id'
=>
$supplierId
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'供应商发货地址'
,
'address'
=>
$supplier
[
'supplier_address'
]
];
}
if
(
$supplierAddress
[
'address_type'
]
==
2
)
{
$address
=
[
'source_id'
=>
$supplierId
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'供应商退货地址'
,
'address'
=>
$supplier
[
'supplier_address'
]
];
}
if
(
!
empty
(
$address
))
{
$addressData
[]
=
$address
;
}
}
$params
=
[
'company_name_cn'
=>
$supplier
[
'supplier_name'
],
'company_name_en'
=>
$supplier
[
'supplier_name'
],
'register_address'
=>
$supplier
[
'supplier_name'
],
'business_license'
=>
$businessLicense
,
'company_id'
=>
1
,
'create_uid'
=>
$supplier
[
'create_uid'
],
'create_name'
=>
$supplier
[
'create_name'
],
'source_system_id'
=>
1
,
'address_data'
=>
$addressData
,
];
$url
=
config
(
'website.UnitedDataDomain'
)
.
'/sync/Company/checkCompanyEntity'
;
$result
=
curl
(
$url
,
$params
);
$result
=
json_decode
(
$result
,
true
);
if
(
array_get
(
$result
,
'code'
)
===
0
)
{
return
$result
[
'data'
][
'result'
];
}
\Log
::
error
(
json_encode
(
$result
));
return
'一体化校验实体名单失败,请联系管理员'
;
}
}
app/Http/Services/SupplierAddressService.php
View file @
52f32859
...
...
@@ -6,6 +6,7 @@ namespace App\Http\Services;
use
App\Model\LogModel
;
use
App\Model\SupplierAddressModel
;
use
App\Model\SupplierAttachmentsModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContactModel
;
use
http\Exception\InvalidArgumentException
;
...
...
@@ -75,10 +76,11 @@ class SupplierAddressService
$supplier
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
select
([
'supplier_id'
,
'supplier_code'
,
'supplier_name'
,
'supplier_address'
,
'create_name'
,
'create_uid'
,
]);
])
->
first
()
->
toArray
()
;
$oldSupplierAddress
=
$supplier
[
'supplier_address'
];
//收发货地址
$addressData
=
SupplierAddressModel
::
where
(
'supplier_id'
,
$supplierId
)
->
pluck
(
'address'
,
'address_type'
)
->
toArray
();
...
...
@@ -99,7 +101,7 @@ class SupplierAddressService
if
(
$oldShippingAddress
!=
$shippingAddress
)
{
$changedAddress
[]
=
[
'source_id'
=>
$supplierId
,
'source_code'
=>
$supplier
Id
,
'source_code'
=>
$supplier
[
'supplier_code'
]
,
'address_type'
=>
'供应商收货地址'
,
'address'
=>
$shippingAddress
,
];
...
...
@@ -107,16 +109,16 @@ class SupplierAddressService
if
(
$oldReturnAddress
!=
$returnAddress
)
{
$changedAddress
[]
=
[
'source_id'
=>
$supplierId
,
'source_code'
=>
$supplier
Id
,
'source_code'
=>
$supplier
[
'supplier_code'
]
,
'address_type'
=>
'供应商退货地址'
,
'address'
=>
$returnAddress
,
];
}
$businessLicense
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'field_name'
,
'business_license'
)
->
value
(
'file_url'
);
//构建修改地址库请求数据
$params
=
[
'company_name_cn'
=>
$supplier
[
'supplier_name'
],
'business_license'
=>
''
,
'business_license'
=>
$businessLicense
,
'source_system_id'
=>
1
,
'create_uid'
=>
$supplier
[
'create_uid'
],
'create_name'
=>
$supplier
[
'create_name'
],
...
...
@@ -124,6 +126,7 @@ class SupplierAddressService
];
$url
=
config
(
'website.UnitedDataDomain'
)
.
'/sync/updateAddress'
;
//dd($params);
$result
=
curl
(
$url
,
$params
);
$result
=
json_decode
(
$result
,
true
);
if
(
array_get
(
$result
,
'code'
)
!=
0
)
{
...
...
app/Http/Services/SupplierService.php
View file @
52f32859
...
...
@@ -257,13 +257,15 @@ class SupplierService
$channel
[
'system_tags'
]
=
trim
(
implode
(
','
,
$channel
[
'system_tags'
]),
','
);
$supplierAddressService
=
new
SupplierAddressService
();
//校验是否需要同步修改地址给一体化
$supplierAddressService
->
updateUnitedAddress
(
$supplierId
,
$channel
[
'supplier_address'
],
$address
[
'shipping_address'
],
$address
[
'return_address'
]);
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
update
(
$channel
);
//保存地址
$supplierAddressService
=
new
SupplierAddressService
();
$supplierAddressService
->
saveAddress
(
$address
);
//校验是否需要同步修改地址给一体化
$supplierAddressService
->
updateUnitedAddress
(
$supplierId
,
$channel
[
'supplier_address'
],
$address
[
'shipping_address'
],
$address
[
'return_address'
]);
//保存附加费
$extraFaxService
=
new
SupplierExtraFeeService
();
$extraFaxService
->
saveSupplierExtraFee
(
$extraFax
);
...
...
@@ -374,6 +376,11 @@ class SupplierService
$redis
->
hset
(
'supplier_status_before_disable'
,
$supplierId
,
$newSupplier
[
'status'
]);
}
//一体化新流程,如果是新建,新建完了以后还要去请求一次验证实体名单的接口,因为只有新建完才有具体的地址source_id这些东西
if
(
empty
(
$channel
[
'supplier_id'
]))
{
(
new
CompanyService
())
->
checkSupplierCompanyAndAddress
(
$supplierId
);
}
//这里有个申请审核的判断逻辑
//如果是申请审核,并且原来的状态不是已通过,无论什么情况,都要变成审核中,如果是已通过,那么就要走下面的判断是否要忽略审核流程
if
(
$isAudit
&&
$oldSupplier
[
'status'
]
==
SupplierChannelModel
::
STATUS_PASSED
&&
!
$needAudit
&&
!
empty
(
$channel
[
'supplier_id'
]))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment