/**
  * absence log
  *
  * @return void
  * @author 
  **/
 public function generate()
 {
     Log::info('Running PointExpireQueue Generator command @' . date('Y-m-d H:i:s'));
     $clients = ClientTemplate::get();
     foreach ($clients as $key => $value) {
         $points = PointLog::debit(true)->onactive([Carbon::parse(' + 1 month')->startOfDay()->format('Y-m-d H:i:s'), Carbon::parse(' + 1 month')->endOfDay()->format('Y-m-d H:i:s')])->haventgetcut(true)->get();
         if (count($points) > 0) {
             $policies = new Store();
             $policies = $policies->default(true)->get()->toArray();
             $store = [];
             foreach ($policies as $key => $value2) {
                 $store[$value2['type']] = $value2['value'];
             }
             $store['action'] = $store['url'] . '/product';
             DB::beginTransaction();
             $parameter['store'] = $store;
             $parameter['template'] = $value['located'];
             $parameter['on'] = Carbon::parse(' + 1 month')->format('Y-m-d H:i:s');
             $queue = new Queue();
             $queue->fill(['process_name' => 'point:expire', 'parameter' => json_encode($parameter), 'total_process' => count($points), 'task_per_process' => 1, 'process_number' => 0, 'total_task' => count($points), 'message' => 'Initial Commit']);
             if (!$queue->save()) {
                 DB::rollback();
                 Log::error('Save queue on PointExpireQueue command ' . json_encode($queue->getError()));
             } else {
                 DB::Commit();
             }
         }
     }
     return true;
 }
예제 #2
0
 function __construct()
 {
     $this->clientId = \LucaDegasperi\OAuth2Server\Facades\Authorizer::getClientId();
     $template = \App\Models\ClientTemplate::clientid($this->clientId)->first();
     if (!$template) {
         \App::abort(404);
     }
     $this->template = $template['located'];
 }