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
1495c88d
authored
Aug 11, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
数据逻辑准备
parent
658d3b6c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
57 deletions
app/Http/Services/DataService.php
app/Http/Transformers/SupplierTransformer.php
app/Http/routes.php
app/Presenters/Filter/TransformableTimeIntervalPresenter.php
app/Http/Services/DataService.php
View file @
1495c88d
...
...
@@ -20,14 +20,48 @@ use Maatwebsite\Excel\Facades\Excel;
//这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多
class
DataService
{
public
function
initSystemTag
()
{
$tagList
=
[
1
=>
'临时供应商'
,
2
=>
'优质供应商'
,
3
=>
'客户指定供应商'
,
4
=>
'开票不及时'
,
5
=>
'跳票'
,
];
$client
=
new
Client
([
'base_uri'
=>
config
(
'website.TagUrl'
),
]);
foreach
(
$tagList
as
$tag
)
{
//构建请求参数
$params
=
[
$tag
=>
[
'tag_use'
=>
14
,
'tag_type'
=>
2
,
'remark'
=>
''
,
'creator'
=>
1000
,
'creator_name'
=>
'admin'
,
'status'
=>
1
,
]
];
$response
=
$client
->
post
(
'/create'
,
[
RequestOptions
::
JSON
=>
$params
,
]);
}
// dd($response->getBody()->getContents());
}
//20210722
//转移文件数据(之前是只存到一个字段,现在要存到一张表里面去)
public
function
transferFileData
()
{
//先找出所有上传文件非空的供应商
$model
=
new
SupplierChannelModel
();
$suppliers
=
$model
->
where
(
'qualification_photos'
,
'!='
,
''
)
->
where
(
'is_type'
,
0
)
->
get
()
->
toArray
();
$suppliers
=
$model
->
where
(
'qualification_photos'
,
'!='
,
''
)
->
get
()
->
toArray
();
$attachmentModel
=
new
SupplierAttachmentModel
();
foreach
(
$suppliers
as
$key
=>
$supplier
)
{
$supplierId
=
$supplier
[
'supplier_id'
];
...
...
@@ -85,72 +119,36 @@ class DataService
$suppliers
=
$model
->
where
(
function
(
$q
)
{
$q
->
where
(
'channel_uid'
,
'!='
,
''
)
->
orWhere
(
'purchase_uid'
,
'!='
,
''
);
})
->
where
(
'is_type'
,
1
)
->
get
()
->
toArray
();
// if (count($suppliers) > 1709) {
// dd("数量有问题");
// }
// dd(count($suppliers));
if
(
count
(
$suppliers
)
>
1670
)
{
dd
(
"数量有问题"
);
}
$redis
=
new
RedisModel
();
//非正式供应商中存在渠道员/采购员,将供应商改为正式供应商
foreach
(
$suppliers
as
$supplier
)
{
//先查询是否有重复的供应商
$count
=
$model
->
where
(
'supplier_name'
,
$supplier
[
'supplier_name'
])
->
count
();
if
(
$count
>
1
)
{
dd
(
$supplier
[
'supplier_name'
]);
continue
;
}
//同时记录被修改的supplier_id列表到redis以防万一
$redis
->
hset
(
'lie_change_is_type_suppliers'
,
$supplier
[
'supplier_id'
],
json_encode
(
$supplier
));
//没有的话直接修改成
审核中
,并且转正
//没有的话直接修改成
待审核
,并且转正
$model
->
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'update_time'
=>
time
(),
//
'update_time' => time(),
'is_type'
=>
0
,
'status'
=>
1
'status'
=>
0
]);
}
}
public
function
initSystemTag
()
{
$tagList
=
[
1
=>
'标签1'
,
2
=>
'标签2'
,
3
=>
'标签3'
,
4
=>
'标签4'
,
];
$tagList
=
[
5
=>
'客户指定供应商'
,
];
$client
=
new
Client
([
'base_uri'
=>
config
(
'website.TagUrl'
),
]);
foreach
(
$tagList
as
$tag
)
{
//构建请求参数
$params
=
[
$tag
=>
[
'tag_use'
=>
14
,
'tag_type'
=>
2
,
'remark'
=>
''
,
'creator'
=>
1000
,
'creator_name'
=>
'admin'
,
'status'
=>
1
,
]
];
$response
=
$client
->
post
(
'/create'
,
[
RequestOptions
::
JSON
=>
$params
,
]);
dd
(
$response
->
getBody
()
->
getContents
());
}
}
//替换老的品牌选择成为新的标准品牌id
public
function
replaceStandardBrandId
()
{
$supplierModel
=
new
SupplierChannelModel
();
$suppliers
=
$supplierModel
->
where
(
'main_brands'
,
'!='
,
''
)
->
get
()
->
toArray
();
$suppliers
=
$supplierModel
->
where
(
'main_brands'
,
'!='
,
''
)
->
limit
(
20
)
->
get
()
->
toArray
();
$redis
=
new
RedisModel
();
foreach
(
$suppliers
as
$supplier
)
{
$mainBrands
=
explode
(
','
,
$supplier
[
'main_brands'
]);
...
...
@@ -158,20 +156,23 @@ class DataService
foreach
(
$mainBrands
as
$brandId
)
{
//找标准品牌ID,没有直接跳过
$standardBrandId
=
$redis
->
hget
(
'standard_brand_mapping'
,
$brandId
);
if
(
empty
(
$standardBrandId
))
{
if
(
empty
(
$standardBrandId
)
or
empty
(
$brandId
)
)
{
continue
;
}
$standardBrandIds
[]
=
$standardBrandId
;
}
print_r
(
$mainBrands
);
print_r
(
$standardBrandIds
);
echo
PHP_EOL
;
if
(
!
empty
(
$standardBrandIds
))
{
$standardBrandIdsStr
=
implode
(
','
,
$standardBrandIds
);
}
else
{
$standardBrandIdsStr
=
''
;
}
//
$supplierModel->where('supplier_id', $supplier['supplier_id'])->update([
//
'main_brands' => $standardBrandIdsStr
//
]);
print_r
(
$standardBrandIds
);
$supplierModel
->
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'main_brands'
=>
$standardBrandIdsStr
]);
}
}
}
...
...
app/Http/Transformers/SupplierTransformer.php
View file @
1495c88d
...
...
@@ -174,7 +174,7 @@ class SupplierTransformer
$brandNames
=
''
;
foreach
(
$brands
as
$brand
)
{
$brand
=
json_decode
(
$brand
,
true
);
$brandNames
=
$brandNames
.
$brand
[
'brand_name'
];
$brandNames
=
$brandNames
.
' | '
.
$brand
[
'brand_name'
];
}
return
$brandNames
;
}
...
...
app/Http/routes.php
View file @
1495c88d
...
...
@@ -45,7 +45,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
$service
=
new
\App\Http\Services\DataService
();
$service
->
initSystemTag
();
$service
->
changeSupplierIsTypeByCheckChannelUidOrPurchaseUid
();
// $service->
initSystemTag
();
// $service->
transferFileData
();
// $service->transferFileData
();
// $service->
changeSupplierIsTypeByCheckChannelUidOrPurchaseUid
();
// $service->
replaceStandardBrandId
();
});
app/Presenters/Filter/TransformableTimeIntervalPresenter.php
View file @
1495c88d
...
...
@@ -13,7 +13,7 @@ class TransformableTimeIntervalPresenter
$unique
=
"unique_"
.
mt_rand
(
1
,
100000
);
$defaultKey
=
array_keys
(
$map
)[
0
];
$todayTimeInterval
=
Carbon
::
now
()
->
startOfDay
()
->
toDateString
()
.
' ~ '
.
Carbon
::
now
()
->
addDay
(
1
)
->
toDateString
();
$threeDayTimeInterval
=
Carbon
::
now
()
->
subDay
(
3
)
->
toDateString
()
.
' ~ '
.
Carbon
::
now
()
->
addDay
(
1
)
->
toDateString
();
$threeDayTimeInterval
=
Carbon
::
now
()
->
subDay
(
2
)
->
toDateString
()
.
' ~ '
.
Carbon
::
now
()
->
addDay
(
1
)
->
toDateString
();
$thisWeekTimeInterval
=
Carbon
::
now
()
->
startOfWeek
()
->
toDateString
()
.
' ~ '
.
Carbon
::
now
()
->
addDay
(
1
)
->
toDateString
();
$thisMonthTimeInterval
=
Carbon
::
now
()
->
startOfMonth
()
->
toDateString
()
.
' ~ '
.
Carbon
::
now
()
->
addDay
(
1
)
->
toDateString
();
$html
=
<<<EOF
...
...
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