|
|
|
@ -9,9 +9,6 @@ use App\Models\OrderProductItem; |
|
|
|
use App\Models\Supplier; |
|
|
|
use App\Service\SmsService; |
|
|
|
use App\Traits\SmsTraits; |
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
|
|
|
use Illuminate\Queue\InteractsWithQueue; |
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
class OrderEventSubscriber |
|
|
|
{ |
|
|
|
@ -22,20 +19,20 @@ class OrderEventSubscriber |
|
|
|
$sms = new SmsService(); |
|
|
|
//退款通知
|
|
|
|
if ($order->isDirty('status') && $order->status == OrderStatus::REFUNDING) { |
|
|
|
$mobile = Agent::query()->where('id',$order->agent_id)->value('contact_phone'); |
|
|
|
$mobile = Agent::query()->where('id',$order->agent_id)->value('contact_mobile'); |
|
|
|
$sms->send('refund', [$order->order_no, SmsTraits::$systeaNameText['agent']], [$mobile]); |
|
|
|
} |
|
|
|
|
|
|
|
//付款通知
|
|
|
|
if ($order->isDirty('status') && ($order->status == OrderStatus::PAY_EARNEST || $order->status == OrderStatus::PAID)) { |
|
|
|
//通知代理商
|
|
|
|
$mobile = Agent::query()->where('id',$order->agent_id)->value('contact_phone'); |
|
|
|
$mobile = Agent::query()->where('id',$order->agent_id)->value('contact_mobile'); |
|
|
|
if (!empty($mobile)) { |
|
|
|
$sms->send('order', [$order->order_no, SmsTraits::$systeaNameText['agent']], [$mobile]); |
|
|
|
} |
|
|
|
//通知供应商
|
|
|
|
$supplierIds = OrderProductItem::query()->with('supplier')->where('order_id', $order->id)->distinct()->pluck('supplier_id'); |
|
|
|
$phone = Supplier::query()->whereIn('id', $supplierIds)->pluck('contact_phone')->toArray(); |
|
|
|
$phone = Supplier::query()->whereIn('id', $supplierIds)->pluck('contact_mobile')->toArray(); |
|
|
|
if (!empty($phone)) { |
|
|
|
$sms->send('order', [$order->order_no, SmsTraits::$systeaNameText['supplier']], $phone);//供应商
|
|
|
|
} |
|
|
|
@ -49,12 +46,12 @@ class OrderEventSubscriber |
|
|
|
} |
|
|
|
//通知供应商
|
|
|
|
$supplierIds = OrderProductItem::query()->with('supplier')->where('order_id', $order->id)->distinct()->pluck('supplier_id'); |
|
|
|
$phone = Supplier::query()->whereIn('id', $supplierIds)->pluck('contact_phone')->toArray(); |
|
|
|
$phone = Supplier::query()->whereIn('id', $supplierIds)->pluck('contact_mobile')->toArray(); |
|
|
|
if(!empty($phone)) { |
|
|
|
$sms->send('verify', [$order->order_no, SmsTraits::$systeaNameText['supplier']], $phone);//供应商
|
|
|
|
} |
|
|
|
//通知代理商
|
|
|
|
$mobile = Agent::query()->where('id',$order->agent_id)->value('contact_phone'); |
|
|
|
$mobile = Agent::query()->where('id',$order->agent_id)->value('contact_mobile'); |
|
|
|
if (!empty($mobile)) { |
|
|
|
$sms->send('verify', [$order->order_no, SmsTraits::$systeaNameText['agent']], [$mobile]);//代理商
|
|
|
|
} |
|
|
|
|