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
99ae5d21
authored
May 30, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化批量设置有效期
parent
b54064f6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
9 deletions
app/Http/Services/DataService.php
app/Http/Services/LogService.php
app/Http/Services/SkuService.php
app/Http/routes.php
app/Http/Services/DataService.php
View file @
99ae5d21
...
@@ -1203,6 +1203,10 @@ class DataService
...
@@ -1203,6 +1203,10 @@ class DataService
$suppliers
=
SupplierChannelModel
::
where
(
'main_brands'
,
'!='
,
''
)
->
where
(
'is_type'
,
0
)
->
get
()
->
toArray
();
$suppliers
=
SupplierChannelModel
::
where
(
'main_brands'
,
'!='
,
''
)
->
where
(
'is_type'
,
0
)
->
get
()
->
toArray
();
$redis
=
new
RedisModel
();
$redis
=
new
RedisModel
();
foreach
(
$suppliers
as
$supplier
)
{
foreach
(
$suppliers
as
$supplier
)
{
if
(
DataManageModel
::
where
(
'canal'
,
$supplier
[
'supplier_code'
])
->
where
(
'is_type'
,
0
)
->
exists
())
{
dump
(
"大数据供应商"
);
continue
;
}
if
(
trim
(
$supplier
[
'main_brands'
],
','
))
{
if
(
trim
(
$supplier
[
'main_brands'
],
','
))
{
$mainBrands
=
explode
(
','
,
trim
(
$supplier
[
'main_brands'
],
','
));
$mainBrands
=
explode
(
','
,
trim
(
$supplier
[
'main_brands'
],
','
));
$ruler
=
$redis
->
hget
(
'supplier_sku_upload_ruler_v2'
,
$supplier
[
'supplier_id'
]);
$ruler
=
$redis
->
hget
(
'supplier_sku_upload_ruler_v2'
,
$supplier
[
'supplier_id'
]);
...
@@ -1220,7 +1224,7 @@ class DataService
...
@@ -1220,7 +1224,7 @@ class DataService
//初始化品牌数量限制(还要跳过API对接的供应商)
//初始化品牌数量限制(还要跳过API对接的供应商)
public
function
initialMainBrandsLimit
()
public
function
initialMainBrandsLimit
()
{
{
$suppliers
=
SupplierChannelModel
::
where
(
'is_type'
,
0
)
->
get
()
->
toArray
();
$suppliers
=
SupplierChannelModel
::
where
(
'is_type'
,
0
)
->
where
(
'main_brands_limit'
,
0
)
->
get
()
->
toArray
();
foreach
(
$suppliers
as
$supplier
)
{
foreach
(
$suppliers
as
$supplier
)
{
//判断是否是API对接的供应商
//判断是否是API对接的供应商
if
(
DataManageModel
::
where
(
'canal'
,
$supplier
[
'supplier_code'
])
->
where
(
'is_type'
,
0
)
->
exists
())
{
if
(
DataManageModel
::
where
(
'canal'
,
$supplier
[
'supplier_code'
])
->
where
(
'is_type'
,
0
)
->
exists
())
{
...
...
app/Http/Services/LogService.php
View file @
99ae5d21
...
@@ -30,7 +30,7 @@ class LogService
...
@@ -30,7 +30,7 @@ class LogService
}
}
//批量添加日志
//批量添加日志
public
function
BatchAddLogs
(
$supplierIds
,
$type
,
$action
,
$content
,
$remark
)
public
function
BatchAddLogs
(
$supplierIds
,
$type
,
$action
,
$content
,
$remark
=
''
)
{
{
$adminId
=
request
()
->
user
->
userId
;
$adminId
=
request
()
->
user
->
userId
;
$adminName
=
request
()
->
user
->
name
;
$adminName
=
request
()
->
user
->
name
;
...
@@ -47,7 +47,6 @@ class LogService
...
@@ -47,7 +47,6 @@ class LogService
'add_time'
=>
time
(),
'add_time'
=>
time
(),
];
];
}
}
$model
=
new
LogModel
();
$model
=
new
LogModel
();
return
$model
->
insert
(
$data
);
return
$model
->
insert
(
$data
);
}
}
...
...
app/Http/Services/SkuService.php
View file @
99ae5d21
...
@@ -361,9 +361,9 @@ class SkuService
...
@@ -361,9 +361,9 @@ class SkuService
$redis
=
new
RedisModel
();
$redis
=
new
RedisModel
();
//批量设置
//批量设置
if
(
$setType
==
1
)
{
if
(
$setType
==
1
)
{
$supplier
s
=
SupplierChannelModel
::
where
(
'supplier_group'
,
$supplierGroup
)
->
select
()
->
toArray
();
$supplier
Ids
=
SupplierChannelModel
::
where
(
'supplier_group'
,
$supplierGroup
)
->
where
(
'is_type'
,
0
)
$supplierIds
=
array_column
(
$suppliers
,
'supplier_ids'
);
->
pluck
(
'supplier_id'
)
->
toArray
(
);
$supplierIds
=
collect
(
$supplierIds
)
->
chunk
(
1
00
)
->
toArray
();
$supplierIds
=
collect
(
$supplierIds
)
->
chunk
(
3
00
)
->
toArray
();
foreach
(
$supplierIds
as
$supplierIdList
)
{
foreach
(
$supplierIds
as
$supplierIdList
)
{
//先去批量设置过期时间限制天数
//先去批量设置过期时间限制天数
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$supplierIdList
)
->
update
([
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$supplierIdList
)
->
update
([
...
@@ -378,9 +378,11 @@ class SkuService
...
@@ -378,9 +378,11 @@ class SkuService
$originDays
=
$originDays
?
$originDays
.
'天'
:
'[ ]'
;
$originDays
=
$originDays
?
$originDays
.
'天'
:
'[ ]'
;
}
}
$ruler
[
'upload_validity_period'
]
=
$cpTimeDay
;
$ruler
[
'upload_validity_period'
]
=
$cpTimeDay
;
(
new
SupplierService
())
->
saveSkuCpTimeRulerToRedis
(
$supplierId
,
$ruler
);
$ruler
=
json_encode
(
$ruler
);
(
new
LogService
())
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修由'
.
$originDays
.
'改为'
.
$cpTimeDay
.
'天'
);
$redis
->
hset
(
'supplier_sku_upload_ruler_v2'
,
$supplierId
,
$ruler
);
}
}
(
new
LogService
())
->
BatchAddLogs
(
$supplierIdList
,
LogModel
::
UPDATE_OPERATE
,
'批量配置供应商sku上架有效期'
,
'上架有效期修改为'
.
$cpTimeDay
.
'天'
);
}
}
}
}
...
...
app/Http/routes.php
View file @
99ae5d21
...
@@ -67,7 +67,8 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
...
@@ -67,7 +67,8 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
(
new
\App\Http\Services\DataService
())
->
deleteSupplierAccount
();
(
new
\App\Http\Services\DataService
())
->
initialMainBrandsLimit
();
(
new
\App\Http\Services\DataService
())
->
initialMainBrandsToSkuRuler
();
// \App\Model\SupplierChannelModel::where('supplier_name', '深圳市金开盛电子有限公司')->update([
// \App\Model\SupplierChannelModel::where('supplier_name', '深圳市金开盛电子有限公司')->update([
// 'status' => 2,
// 'status' => 2,
// 'update_time' => time(),
// 'update_time' => time(),
...
...
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