Beispiel #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $dbox = Boxstatus::where('appname', '=', Config::get('jex.tracker_app'))->where('deliveryStatus', '=', Config::get('jayon.trans_status_mobile_delivered'))->get();
     if ($dbox) {
         foreach ($dbox as $dbx) {
             print 'box status : ' . $dbx->deliveryId . ' ' . $dbx->boxId . ' ' . $dbx->deliveryStatus . "\r\n";
             $box = Box::where('delivery_id', '=', $dbx->deliveryId)->where(function ($q) use($dbx) {
                 $q->where('box_id', '=', intval($dbx->boxId))->orWhere('box_id', '=', strval($dbx->boxId));
             })->first();
             if ($box) {
                 print 'box before : ' . $box->delivery_id . ' ' . $box->box_id . ' ' . $box->deliveryStatus . "\r\n";
                 $box->deliveryStatus = $dbx->deliveryStatus;
                 print 'box after : ' . $box->delivery_id . ' ' . $box->box_id . ' ' . $box->deliveryStatus . "\r\n";
                 $box->save();
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postBoxstatus()
 {
     date_default_timezone_set('Asia/Jakarta');
     $key = \Input::get('key');
     $appname = \Input::has('app') ? \Input::get('app') : 'app.name';
     //$user = \Apiauth::user($key);
     $user = \Device::where('key', '=', $key)->first();
     if (!$user) {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'device not found, upload image failed'));
         return \Response::json(array('status' => 'ERR:NODEVICE', 'timestamp' => time(), 'message' => $image_id));
     }
     $json = \Input::all();
     $batch = \Input::get('batch');
     $result = array();
     foreach ($json as $j) {
         if (isset($j['logId'])) {
             if (isset($j['datetimestamp'])) {
                 $j['mtimestamp'] = new \MongoDate(strtotime($j['datetimestamp']));
             }
             $log = \Boxstatus::where('logId', $j['logId'])->first();
             if ($log) {
                 $result[] = array('status' => 'OK', 'timestamp' => time(), 'message' => $j['logId']);
             } else {
                 /*
                                     $bs = array();
                                     foreach($j as $k=>$v){
                                         $bs[$this->camel_to_underscore($k)] = $v;
                                     }*/
                 $j['appname'] = $appname;
                 \Boxstatus::insert($j);
                 $result[] = array('status' => 'OK', 'timestamp' => time(), 'message' => $j['logId']);
             }
         }
     }
     //print_r($result);
     //die();
     $actor = $user->identifier . ' : ' . $user->devname;
     \Event::fire('log.api', array($this->controller_name, 'get', $actor, 'sync scan log'));
     return Response::json($result);
 }
 public function lastBoxStatus($device_key, $delivery_id, $fulfillment_code, $box_id)
 {
     $last = \Boxstatus::where('deliveryId', '=', $delivery_id)->where('deviceKey', '=', $device_key)->where('appname', '=', \Config::get('jex.tracker_app'))->where('boxId', '=', strval($box_id))->orderBy('mtimestamp', 'desc')->first();
     //print_r($last);
     if ($last) {
         return $last->status;
     } else {
         return 'out';
     }
 }