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
8af51955
authored
Jan 16, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善初步判断
parent
c1c07301
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
app/Http/Services/SkuService.php
app/Http/Services/SkuService.php
View file @
8af51955
...
...
@@ -15,6 +15,7 @@ use App\Model\SupplierChannelModel;
use
PhpAmqpLib\Message\AMQPMessage
;
use
Illuminate\Support\Facades\Redis
;
use
App\Http\Controllers\Filter\SkuListFilter
;
use
Exception
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
class
SkuService
extends
BaseService
...
...
@@ -327,6 +328,74 @@ class SkuService extends BaseService
{
try
{
$skuIds
=
explode
(
','
,
$data
[
'sku_ids'
]);
//上架时验证cp_time限制
if
(
$data
[
'operate_type'
]
==
SkuService
::
OPERATE_TYPE_PUTAWAY
)
{
//商品类型枚举
$goodsLabelMap
=
config
(
'field.SkuGoodsLabel'
);
$invalidSkuIds
=
[];
$now
=
time
();
$redis
=
new
RedisModel
();
$skuList
=
$redis
->
hmget
(
'sku'
,
$skuIds
);
$skuList
=
array_filter
(
$skuList
,
function
(
$value
)
{
return
$value
;
});
$supplierCpTimeMap
=
SupplierChannelModel
::
select
(
'supplier_code'
,
'cp_time_day'
,
'futures_cp_time_day'
)
->
whereIn
(
'supplier_code'
,
array_column
(
$skuList
,
'canal'
))
->
pluck
(
'cp_time_day'
,
'supplier_code'
)
->
toArray
();
foreach
(
$skuIds
as
$skuId
)
{
//获取goods_tag信息
$goodsTagsStr
=
$redis
->
hget
(
'goods_tag'
,
$skuId
);
$isFutures
=
false
;
if
(
$goodsTagsStr
)
{
$goodsTagsData
=
json_decode
(
$goodsTagsStr
,
true
);
if
(
!
empty
(
$goodsTagsData
[
'goods_label'
]))
{
$goodsLabelType
=
(
int
)
$goodsTagsData
[
'goods_label'
];
$goodsLabel
=
isset
(
$goodsLabelMap
[
$goodsLabelType
])
?
$goodsLabelMap
[
$goodsLabelType
]
:
''
;
//判断是否是期货(标签名称包含"期货")
if
(
strpos
(
$goodsLabel
,
'期货'
)
!==
false
)
{
$isFutures
=
true
;
}
}
}
//获取SKU信息以获取供应商编码
$skuInfo
=
isset
(
$skuList
[
$skuId
])
?
json_decode
(
$skuList
[
$skuId
],
true
)
:
null
;
if
(
!
$skuInfo
||
empty
(
$skuInfo
[
'canal'
]))
{
$invalidSkuIds
[]
=
$skuId
;
continue
;
}
$supplierCode
=
$skuInfo
[
'canal'
];
//获取对应的cp_time限制
if
(
!
isset
(
$supplierCpTimeMap
[
$supplierCode
]))
{
$invalidSkuIds
[]
=
$skuId
;
continue
;
}
$cpTimeLimit
=
$isFutures
?
$supplierCpTimeMap
[
$supplierCode
][
'futures_cp_time_day'
]
:
$supplierCpTimeMap
[
$supplierCode
][
'cp_time_day'
];
// -1表示不限制
if
(
$cpTimeLimit
==
-
1
)
{
continue
;
}
//计算允许的最大cp_time(当前时间+限制天数)
$maxCpTime
=
$now
+
(
$cpTimeLimit
*
86400
);
//获取传入的cp_time(从请求中获取,这里假设传入的是2051193600)
$inputCpTime
=
$data
[
'cp_time'
];
//验证cp_time是否超过限制
if
(
$inputCpTime
>
$maxCpTime
)
{
$invalidSkuIds
[]
=
$skuId
;
}
}
//如果有不符合要求的SKU,全部拒绝
if
(
!
empty
(
$invalidSkuIds
))
{
return
new
Exception
(
"以下SKU的cp_time超过限制:"
.
implode
(
'</br>'
,
$invalidSkuIds
));
}
}
$supplierCodes
=
explode
(
','
,
$data
[
'supplier_codes'
]);
//构建队列数据
//上架
...
...
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