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
e8b06c67
authored
Jul 22, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix
parent
6902a708
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
40 deletions
.codeiumignore
app/Console/Commands/SupplierRecallMailRemind.php
.codeiumignore
View file @
e8b06c67
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
vendor/
storage/
public/
app/Console/Commands/SupplierRecallMailRemind.php
View file @
e8b06c67
...
...
@@ -31,11 +31,11 @@ class SupplierRecallMailRemind extends Command
public
function
handle
()
{
$today
=
Carbon
::
today
();
$contracts
=
SupplierContractModel
::
with
(
'supplier'
)
->
where
(
'recall_time'
,
'!='
,
0
)
->
get
();
// $contracts = SupplierContractModel::with('supplier')->where('recall_time', '!=', 0)->get();
$contracts
=
SupplierContractModel
::
with
(
'supplier'
)
->
where
(
'recall_time'
,
0
)
->
get
();
$adminUserService
=
new
AdminUserService
();
$messageService
=
new
MessageService
();
$remindDays
=
[
30
,
7
];
foreach
(
$contracts
as
$contract
)
{
//判断有没有上架的sku,通过搜索接口查询
$map
[
'p'
]
=
1
;
...
...
@@ -45,38 +45,35 @@ class SupplierRecallMailRemind extends Command
$url
=
env
(
'ES_SKU_URL'
,
''
);
$map
[
'show_status'
]
=
1
;
$map
[
'no_rule'
]
=
1122
;
try
{
$url
=
base64_encode
(
$url
.
'?'
.
http_build_query
(
$map
));
$return
=
curl
(
config
(
'website.FootstoneCurlUrl'
)
.
$url
);
$data
=
json_decode
(
$return
,
true
);
if
(
isset
(
$data
[
'error_code'
])
&&
$data
[
'error_code'
]
==
0
)
{
$searchResult
=
$data
[
'data'
][
'goods_id'
];
$skuDataList
=
[];
$redis
=
new
RedisModel
();
$spuRedis
=
Redis
::
connection
(
'spu'
);
foreach
(
$searchResult
as
$goodsId
)
{
$sku
=
json_decode
(
$redis
->
hget
(
'sku'
,
$goodsId
),
true
);
if
(
empty
(
$sku
))
{
continue
;
}
$spu
=
json_decode
(
$spuRedis
->
hget
(
'spu'
,
$sku
[
'spu_id'
]),
true
);
//去获取标准品牌名称
$standardBrandId
=
$spu
[
's_brand_id'
];
$standardBrand
=
$redis
->
hget
(
'standard_brand'
,
$standardBrandId
);
if
(
empty
(
$standardBrand
))
{
continue
;
}
$skuDataList
[]
=
[
'spu_name'
=>
$spu
[
'spu_name'
],
'brand_name'
=>
$standardBrand
[
'brand_name'
],
'stock'
=>
$sku
[
'stock'
],
];
$url
=
base64_encode
(
$url
.
'?'
.
http_build_query
(
$map
));
$return
=
curl
(
config
(
'website.FootstoneCurlUrl'
)
.
$url
);
$data
=
json_decode
(
$return
,
true
);
if
(
isset
(
$data
[
'error_code'
])
&&
$data
[
'error_code'
]
==
0
)
{
$searchResult
=
$data
[
'data'
][
'goods_id'
];
$skuDataList
=
[];
$redis
=
new
RedisModel
();
$spuRedis
=
Redis
::
connection
(
'spu'
);
foreach
(
$searchResult
as
$goodsId
)
{
$sku
=
json_decode
(
$redis
->
hget
(
'sku'
,
$goodsId
),
true
);
if
(
empty
(
$sku
))
{
continue
;
}
$spu
=
json_decode
(
$spuRedis
->
hget
(
'spu'
,
$sku
[
'spu_id'
]),
true
);
//去获取标准品牌名称
$standardBrandId
=
$spu
[
's_brand_id'
];
$standardBrand
=
$redis
->
hget
(
'standard_brand'
,
$standardBrandId
);
if
(
empty
(
$standardBrand
))
{
continue
;
}
}
else
{
$searchResult
=
[];
$standardBrand
=
json_decode
(
$standardBrand
,
true
);
$skuDataList
[]
=
[
'spu_name'
=>
$spu
[
'spu_name'
],
'brand_name'
=>
$standardBrand
[
'brand_name'
],
'stock'
=>
$sku
[
'stock'
],
];
}
}
catch
(
\Exception
$e
)
{
return
$e
->
getMessage
()
;
}
else
{
$searchResult
=
[]
;
}
if
(
empty
(
$searchResult
))
{
continue
;
...
...
@@ -84,7 +81,7 @@ class SupplierRecallMailRemind extends Command
$recallDate
=
Carbon
::
createFromTimestamp
(
$contract
->
recall_time
);
$diff
=
$today
->
diffInDays
(
$recallDate
,
false
);
if
(
!
in_array
(
$diff
,
$remindDays
))
{
continue
;
//
continue;
}
$supplier
=
$contract
->
supplier
;
...
...
@@ -134,13 +131,14 @@ class SupplierRecallMailRemind extends Command
'content'
=>
$content
,
]
];
// 发送邮件
foreach
(
$toEmails
as
$to
)
{
$messageService
->
sendMessage
(
'supplier_recall_remind'
,
$data
,
$to
,
true
);
}
foreach
(
$ccEmails
as
$cc
)
{
$messageService
->
sendMessage
(
'supplier_recall_remind'
,
$data
,
$cc
,
true
);
}
dd
(
$toEmails
,
$ccEmails
);
// // 发送邮件
// foreach ($toEmails as $to) {
// $messageService->sendMessage('supplier_recall_remind', $data, $to, true);
// }
// foreach ($ccEmails as $cc) {
// $messageService->sendMessage('supplier_recall_remind', $data, $cc, true);
// }
$this
->
info
(
"已发送提醒:供应商
{
$supplierName
}
,召回期
{
$recallTimeStr
}
,剩余
{
$diff
}
天"
);
}
}
...
...
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