Commit e8b06c67 by 杨树贤

fix

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