123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace App\Console\Commands;
- use App\Events\TipSend as TipSends;
- use App\Models\Agent\AgentOperationLog;
- use App\Http\Controllers\Admin\StoreController as Sc;
- use App\Models\Order;
- use App\Models\OrderW;
- use App\Models\Store;
- use App\Models\TipWithdraw as Tip;
- use App\Models\User;
- use App\Models\DwbsUser;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\DB;
- use Overtrue\EasySms\EasySms;
- class TipWithdraw extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'tip_withdraw';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '提醒提现';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- Log::info('提示提现发送短信');
- $operation=AgentOperationLog::query()->where('type',4)
- ->where('created_at','>=',Carbon::now()->subMinutes(2))->get();
- foreach($operation as $key=>$val){
- $store=Store::where('user_id',$val->user_id)->first();
- if($store){
- $total = Order::where('store_id',$store->id)->where('status','<','3')->where('is_pay',1)->whereIn('apply_cancel',[0,1,3])->count();
- Log::info($store);
- $store->delete();
- }else{
- $total = 0;
- }
- $sc=new Sc();
- $result=$sc->getAccount($val->user_id);
- $account=$result['pending_amount']+$result['available_amount'];
- Log::info('.............1............');
- if($account > 0 || $total > 0){
- Log::info('..........2...............');
- $tip=Tip::where('user_id',$val->user_id)->first();
- if(empty($tip)){
- Log::info('.............3............');
- DB::beginTransaction();
- Tip::create([
- 'user_id'=>$val->user_id,
- 'num'=>1,
- 'send_at'=>Carbon::now(),
- ]);
- $phone=DwbsUser::withTrashed()->where('id',$val->user_id)->value('mobile');
- $config=config('easysms');
- $easySms = new EasySms($config);
- $content="您的微店铺账号已被删除,请及时处理订单,并完成提现。点击链接进入微店铺 https://dllzff.cn/U1oTQeNj 如已处理请忽略。";
- Log::info('.........4................');
- try{
- $easySms->send($phone, ['content' =>$content ]);
- DB::commit();
- Log::info('短信发送成功');
- } catch (\Overtrue\EasySms\Exceptions\NoGatewayAvailableException $exception) {
- $message = $exception->getException('qcloud')->getMessage();
- DB::rollBack();
- Log::info($message);
- }
- }
- }
- }
- }
- }
|