Commit e2714269 authored by hangjun83's avatar hangjun83

openapi 震坤行邮件

parent 9f49efcd
......@@ -55,7 +55,7 @@ class ZhenkhJob extends Job
$service->hMUpdateOrdersList();
break;
case 'sendMail' :
$service->sendMail();
$service->sendMail('订单确认邮件', '订单号:未确认成功');
default:
}
}
......
......@@ -22,12 +22,12 @@ class MailService{
$this->registerProvider($this->getMailAccountConfig($this->type));
}
public function getMailAccountConfig($type)
public function getMailAccountConfig()
{
$username = env("MAIL_{$type}_USERNAME");
$password = env("MAIL_{$type}_PASSWORD");
$address = env("MAIL_{$type}_FROM_ADDRESS");
$fromName = env("MAIL_{$type}_FROM_NAME");
$username = env("MAIL_USERNAME");
$password = env("MAIL_PASSWORD");
$address = env("MAIL_FROM_ADDRESS");
$fromName = env("MAIL_FROM_NAME");
$config = config('mail');
......@@ -45,11 +45,13 @@ class MailService{
app()->register(\Illuminate\Mail\MailServiceProvider::class);
}
public function send($type, $toUser, $message)
public function sendMail($title, $toUser, $message)
{
$this->setFromType($type)->initSendService();
Mail::to($toUser)->send(new MailTempl([
'message' => $message
]));
$this->setFromType('zkh')->initSendService();
Mail::raw($message,function($mail) use ($toUser, $title){
$mail->to($toUser);
$mail->subject($title);
});
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ class ZhenKhService
$this->apiService = (new ZhenkhApiService(app(ThirdApiPlatformRepository::class)));
$this->rhawnService = app(RhawnChemicalsService::class);
$this->rhawnOrderService = app(RhawnOrdersService::class);
$this->mailService = app(MailService::class);
}
public function orderNoRollBack()
......@@ -331,6 +332,7 @@ class ZhenKhService
{
try{
$orderDelivery = $this->rhawnOrderService->getSorderDeliveryDetail($deliveryCode);
$noMatchGoods = [];
if($orderDelivery){
$expressArray = $this->apiService->getPlatformDataEntries('zkh_order_express','data_values');
if(empty($expressArray)){
......@@ -389,6 +391,7 @@ class ZhenKhService
foreach($orderDelivery as $delivery){
$zkhGoods = $this->rhawnService->getZkhGoodsSku($delivery->p_id);
if(empty($zkhGoods)){
$noMatchGoods[] = $orderNo;
throw new \Exception('对应震坤行商品数据未找到');
}
foreach($zkhGoods as $goods){
......@@ -425,6 +428,10 @@ class ZhenKhService
$this->apiService->storePlatformDataEntries('zkh_delivery_code_'.$deliveryCode,['code' => $deliveryResult['data']]);
}
}
if(!empty($noMatchGoods)){
//发送邮件
$this->sendMail('订单同步邮件', '订单号:'.implode(',',$orderNo).'未同步成功');
}
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(),__CLASS__.':sendDeliveryOrder', 'error');
......@@ -479,7 +486,7 @@ class ZhenKhService
}
if(!$result){
//发送邮件
$this->sendMail('订单确认邮件', '订单号:'.$orderNo.'未确认成功');
}
}
}
......@@ -522,11 +529,11 @@ class ZhenKhService
}
}
public function sendMail()
public function sendMail($title, $message)
{
$mailService = app(MailService::class);
try{
$mailService->send('zkh','hangjun83@126.com','测试邮件');
$mailer = $this->apiService->getPlatformDataEntries('zkh_send_mailer','data_values');
$this->mailService->sendMail($title, $mailer,'震坤行【'.$message.'】,请人工操作!');
}catch(\Throwable $exception){
SimpleLogs::writeLog($exception->getMessage(), __CLASS__.':sendMail', 'error');
return false;
......
......@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\DB;
class PlatformDataEntriesSeeder extends Seeder
{
protected $entries = [
[
/*[
'platform_id' => 27,
'data_key' => 'zkh_order_invoice',
'data_values' => [
......@@ -27,8 +27,34 @@ class PlatformDataEntriesSeeder extends Seeder
'address' => '上海浦东科苑路399号张江创新园5号楼',
'company_phone' => '400-680-9696'
]
]
];
],
[
'platform_id' => 27,
'data_key' => 'sys_delivery_logistics',
'data_values' => [
'JD'=>'京东',
'SF'=>'顺丰',
'ZT'=>'中通',
'YD'=>'韵达',
'ZJS'=>'宅急送',
'DBL'=>'德邦',
'YTO'=>'圆通',
'YZPY'=>'邮政',
'AN'=>'安能',
'STO'=>'申通',
'HHTT'=>'天天',
'WL'=>'物流',
'ziti'=>'自提'
]
],*/
[
'platform_id' => 27,
'data_key' => 'zkh_send_mailer',
'data_values' => [
'it@rhawn.cn','yuxiaohui@rhawn.cn','hangjun@rhawn.cn'
]
] ];
public function run()
{
......
@component('mail::message')
震坤行订单{{$message}}未同步成功,请人工下单!
{{$message}}
@endcomponent
\ No newline at end of file
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 to comment