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,9 +45,8 @@ class SupplierRecallMailRemind extends Command ...@@ -45,9 +45,8 @@ 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'];
...@@ -66,6 +65,7 @@ class SupplierRecallMailRemind extends Command ...@@ -66,6 +65,7 @@ class SupplierRecallMailRemind extends Command
if (empty($standardBrand)) { if (empty($standardBrand)) {
continue; continue;
} }
$standardBrand = json_decode($standardBrand, true);
$skuDataList[] = [ $skuDataList[] = [
'spu_name' => $spu['spu_name'], 'spu_name' => $spu['spu_name'],
'brand_name' => $standardBrand['brand_name'], 'brand_name' => $standardBrand['brand_name'],
...@@ -75,16 +75,13 @@ class SupplierRecallMailRemind extends Command ...@@ -75,16 +75,13 @@ class SupplierRecallMailRemind extends Command
} else { } else {
$searchResult = []; $searchResult = [];
} }
} catch (\Exception $e) {
return $e->getMessage();
}
if (empty($searchResult)) { if (empty($searchResult)) {
continue; continue;
} }
$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