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
182117d0
authored
Jun 25, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复地址类型错误的问题
parent
ee1ebd4c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
7 deletions
app/Http/Services/CompanyService.php
app/Http/Services/SupplierAddressService.php
app/Http/routes.php
app/Http/Services/CompanyService.php
View file @
182117d0
...
...
@@ -132,18 +132,18 @@ class CompanyService
foreach
(
$supplierAddressList
as
$supplierAddress
)
{
if
(
$supplierAddress
[
'address_type'
]
==
1
)
{
$address
=
[
'source_id'
=>
$supplierId
,
'source_id'
=>
$supplierId
.
'_'
.
$supplierAddress
[
'info_id'
]
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'供应商发货地址'
,
'address'
=>
$supplier
[
'supplier_
address'
]
'address'
=>
$supplier
Address
[
'
address'
]
];
}
if
(
$supplierAddress
[
'address_type'
]
==
2
)
{
$address
=
[
'source_id'
=>
$supplierId
,
'source_id'
=>
$supplierId
.
'_'
.
$supplierAddress
[
'info_id'
]
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'供应商退货地址'
,
'address'
=>
$supplier
[
'supplier_
address'
]
'address'
=>
$supplier
Address
[
'
address'
]
];
}
if
(
!
empty
(
$address
))
{
...
...
app/Http/Services/SupplierAddressService.php
View file @
182117d0
...
...
@@ -92,7 +92,7 @@ class SupplierAddressService
//发货地址
$oldShippingAddress
=
$item
[
'address'
];
$oldShippingAddressSourceId
=
$supplierId
.
'_'
.
$item
[
'info_id'
];
}
else
{
}
else
{
//退货地址
$oldReturnAddress
=
$item
[
'address'
];
$oldReturnAddressSourceId
=
$supplierId
.
'_'
.
$item
[
'info_id'
];
...
...
@@ -137,7 +137,6 @@ class SupplierAddressService
];
$url
=
config
(
'website.UnitedDataDomain'
)
.
'/sync/Address/updateAddress'
;
//dd(json_encode($params));
$result
=
curl
(
$url
,
$params
);
$result
=
json_decode
(
$result
,
true
);
\Log
::
error
(
$result
);
...
...
@@ -145,4 +144,88 @@ class SupplierAddressService
\Log
::
error
(
'更新一体化地址库失败 : '
.
json_encode
(
$result
));
}
}
//批量同步地址数据到一体化初始化
public
static
function
initUnitedAddress
()
{
ini_set
(
'memory_limit'
,
-
1
);
//先找出原始地址数据,然后比对
$supplierList
=
SupplierChannelModel
::
where
(
'is_type'
,
0
)
->
select
([
'supplier_id'
,
'supplier_code'
,
'supplier_name'
,
'supplier_address'
,
'create_name'
,
'create_uid'
,
])
->
get
()
->
toArray
();
foreach
(
$supplierList
as
$supplier
)
{
$supplierId
=
$supplier
[
'supplier_id'
];
//收发货地址
$addressData
=
SupplierAddressModel
::
where
(
'supplier_id'
,
$supplierId
)
->
select
([
'info_id'
,
'address'
,
'address_type'
,
'supplier_id'
])
->
get
()
->
toArray
();
$oldShippingAddress
=
$oldReturnAddress
=
''
;
$oldReturnAddressSourceId
=
$oldShippingAddressSourceId
=
''
;
foreach
(
$addressData
as
$item
)
{
if
(
$item
[
'address_type'
]
==
1
)
{
//发货地址
$oldShippingAddress
=
$item
[
'address'
];
$oldShippingAddressSourceId
=
$supplierId
.
'_'
.
$item
[
'info_id'
];
}
else
{
//退货地址
$oldReturnAddress
=
$item
[
'address'
];
$oldReturnAddressSourceId
=
$supplierId
.
'_'
.
$item
[
'info_id'
];
}
}
//比较,如果有变化,则请求一体化接口
$changedAddress
=
[];
if
(
$supplier
[
'supplier_address'
])
{
$changedAddress
[]
=
[
'source_id'
=>
$supplierId
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'注册地址'
,
'address'
=>
$supplier
[
'supplier_address'
],
];
}
if
(
$oldShippingAddress
)
{
$changedAddress
[]
=
[
'source_id'
=>
$oldShippingAddressSourceId
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'收货地址'
,
'address'
=>
$oldShippingAddress
,
];
}
if
(
$oldReturnAddress
)
{
$changedAddress
[]
=
[
'source_id'
=>
$oldReturnAddressSourceId
,
'source_code'
=>
$supplier
[
'supplier_code'
],
'address_type'
=>
'退货地址'
,
'address'
=>
$oldReturnAddress
,
];
}
if
(
empty
(
$changedAddress
))
{
dump
(
'完全没有地址,不同步 : '
.
$supplier
[
'supplier_name'
]);
continue
;
}
$businessLicense
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'field_name'
,
'business_license'
)
->
value
(
'file_url'
);
//构建修改地址库请求数据
$params
=
[
'company_name_cn'
=>
$supplier
[
'supplier_name'
],
'business_license'
=>
$businessLicense
,
'source_system_id'
=>
1
,
'create_uid'
=>
$supplier
[
'create_uid'
],
'create_name'
=>
$supplier
[
'create_name'
],
'address_data'
=>
$changedAddress
,
];
dd
(
1232
);
//改成队列投放
(
new
QueueDeliveryService
())
->
push
(
QueueDeliveryService
::
PUSH_TYPE_SYNC_HTTP
,
'/sync/Address/updateAddress'
,
$params
);
}
}
}
app/Http/routes.php
View file @
182117d0
...
...
@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
(
new
\App\Http\Services\DataService
())
->
checkSupplierBandAccount
();
\App\Http\Services\SupplierAddressService
::
initUnitedAddress
();
});
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