12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Listeners;
- use App\Events\EnoughFive;
- use App\Models\OrderW;
- use App\Models\UserW;
- use App\Models\User;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Http\Request;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- use Overtrue\EasySms\EasySms;
- class EnoughFiveListeners
- {
- /**
- * Create the event listener.
- *
- * @return void
- */
- public function __construct()
- {
- }
- /**
- * Handle the event.
- *
- * @param EnoughFive $event
- * @return void
- */
- public function handle(EnoughFive $event)
- {
- $order_id=$event->data;
- $order=OrderW::where('id',$order_id)->first();
- // 1.计算客户
- $self_phone=UserW::where('id',$order->user_id)->value('phone');
- $self_user=User::where('mobile',$self_phone)->first();
- if(empty($self_user)){
- $self_total=OrderW::query()->where('store_id',$order->store_id)
- ->where(function($query)use($order){
- $query->where(function($que)use($order){
- $que->where('user_id',$order->user_id)->where(function($q){$q->whereNull('recomer_status')->orWhereIn('recomer_status',[0,2]);});
- })->orWhere(function($que)use($order){
- $que->where('recomer_id',$order->user_id)->where(function($q){$q->whereNull('recomer_status')->orWhereIn('recomer_status',[0,1]);});
- });
- })
- ->whereIn('status',[2,3])
- ->sum('total');
- Log::info( $self_total);
- if($self_total>=5){
- Log::info('客户手机号---'.$self_phone);
- $this->sendSMs($self_phone,$self_total,$order->id);
- }
- }
- }
- public function sendSMs($phone,$num,$order_id){
- }
- }
|