1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace App\Servers;
- class BoxUpgradeServer extends BaseServer
- {
- public function main($body)
- {
- $data = $this->decode($body);
- self::log($data, 'BoxUpgradeServer', self::$LOG_MAJOR);
- return $this->response();
- }
- const RESPONSE_SUCCESS = '01';
- const RESPONSE_FAIL = '00';
- protected function response($response_status = self::RESPONSE_FAIL)
- {
- $body = [
- $response_status
- ];
- $body = str_split(implode('', $body), 2);
- return $body;
- }
-
- private function decode($body)
- {
- $i = 0;
- $box_no = self::stitching($body, $i, 5);
- $i += 5;
-
- $code = self::stitching($body, $i, 2);
-
- $i += 2;
-
- $i += 2;
-
- $i += 3;
-
- $i += 1;
-
- $i += 1;
-
- $i += 2;
-
- $box_no = $this->decodeBoxNo($box_no);
- return [
- 'box_no' => $box_no,
- 'code' => $code
- ];
- }
- }
|