Commit e8b06c67 by 杨树贤

fix

parent 6902a708
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
vendor/
storage/
public/
......@@ -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}天");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment