diff --git a/app-api/controllers/AuthDeviceController.php b/app-api/controllers/AuthDeviceController.php
index d3c50b5..583b8e1 100644
--- a/app-api/controllers/AuthDeviceController.php
+++ b/app-api/controllers/AuthDeviceController.php
@@ -2,12 +2,15 @@
namespace app\api\controllers;
-use Yii;
+use Yii;
use common\helpers\Utils;
+use domain\device\DeviceRepository;
+use domain\device\Device;
+use domain\device\DeviceStatus;
use stdClass;
-use function sizeof;
+
use function date;
use function count;
use function time;
@@ -37,29 +40,40 @@ class AuthDeviceController extends BaseController
public function actionIndex()
{
$req = Yii::$app->request;
- $manufacture = $req->post('manufacture');
- $device_id = $req->post('device_id');
- $project = $req->post('project');
- $model = $req->post('model');
+ $manufactureNo = $req->post('manufacture');
+ $deviceId = $req->post('device_id');
+ $projectNo = $req->post('project');
+ $modelNo = $req->post('model');
$sign = $req->post('sign');
- $production = $req->post('production');
+ $productionNo = $req->post('production');
$timestamp = $req->post('timestamp');
$e = new stdClass();
$e->status = 0;
- $e->message = 'fail';
+ $e->message = '授权失败';
$e->serial_no = '';;
$e->mac = '';
$salt = self::SIGN_SALT;
- $makeSign = md5($manufacture . $project. $model . $production . $timestamp . $salt);
+ $makeSign = md5($manufactureNo . $projectNo. $modelNo . $productionNo . $timestamp . $salt);
if ($sign != $makeSign) {
- $e->message = 'sign 有误';
+ $e->message = '签名有误';
return $e;
}
+ // 检测是否授权过了的设备
+ $deviceModel = DeviceRepository::findOne(['device_id' => $deviceId]);
+ if ($deviceModel && DeviceStatus::HAS_AUTH == $deviceModel->status) {
+ $e->mac = $deviceModel->mac;
+ $e->serial_no = $deviceModel->serial_no;
+ $e->status = 1;
+ return $e;
+ }
+ $authResult = Device::authDevice($deviceId, $manufactureNo, $projectNo, $modelNo, $productionNo);
- $e->status = 1;
- $e->message = '授权成功';
- $e->mac = Utils::macGenerate();
+ if ($authResult->success) {
+ $e->mac = $authResult->mac;
+ $e->serial_no = $authResult->serial_no;
+ $e->status = 1;
+ }
return $e;
}
diff --git a/app-ht/modules/device/controllers/DeviceController.php b/app-ht/modules/device/controllers/DeviceController.php
index 5fe448d..927378d 100644
--- a/app-ht/modules/device/controllers/DeviceController.php
+++ b/app-ht/modules/device/controllers/DeviceController.php
@@ -4,10 +4,19 @@ namespace app\ht\modules\device\controllers;
use Yii;
+use yii\base\Exception;
use yii\data\Pagination;
use app\ht\controllers\BaseController;
-use domain\DeviceRepository;
-use domain\DeviceStatus;
+use common\helpers\Utils;
+use domain\device\DeviceStatus;
+use domain\device\CreateBatchRepository;
+use domain\device\Device;
+use domain\device\DeviceRepository;
+use domain\device\models\Device as DeviceModel;
+
+use domain\device\CreateBatch;
+
+use stdClass;
/**
* 设备管理
@@ -22,15 +31,40 @@ class DeviceController extends BaseController
$request = Yii::$app->request;
$serialNo = $request->get('serial_no');
$mac = $request->get('mac');
+ $project = $request->get('project');
+ $model = $request->get('model');
+ $production = $request->get('production');
+ $manufacture = $request->get('manufacture');
+ $deviceId = $request->get('device_id');
+ $status = $request->get('status');
$page = $request->get('page');
$where = [
- 'and'
+ 'and',
+ ['=','a.is_delete', 0]
];
- if (null !== $serialNo) {
- $where[] = ['like', 'serial_no', $serialNo];
+ if (!empty($serialNo)) {
+ $where[] = ['like', 'a.serial_no', $serialNo];
+ }
+ if (!empty($project)) {
+ $where[] = ['like', 'p.name', $project];
+ }
+ if (!empty($model)) {
+ $where[] = ['like', 'mo.name', $model];
+ }
+ if (!empty($production)) {
+ $where[] = ['like', 'pd.name', $production];
+ }
+ if (!empty($mac)) {
+ $where[] = ['like', 'a.mac', $mac];
+ }
+ if (!empty($manufacture)) {
+ $where[] = ['like', 'm.name', $manufacture];
}
- if (isset($mac)) {
- $where[] = ['like', 'mac', $mac];
+ if (!empty($deviceId)) {
+ $where[] = ['like', 'a.device_id', $deviceId];
+ }
+ if (isset($_GET['status']) && -1 != $status) {
+ $where[] = ['=', 'a.status', $status];
}
if (0 >= $page) {
@@ -38,6 +72,7 @@ class DeviceController extends BaseController
}
$pageSize = 20;
$page = ($page -1) * $pageSize;
+ // DeviceRepository::getList($where, $pageSize, $page);
$deviceData = DeviceRepository::getList($where, $pageSize, $page);
$pages = new Pagination(['totalCount' => DeviceRepository::getListCount($where), 'pageSize' => $pageSize]);
$statusList = DeviceStatus::statusLabels(); //
@@ -48,13 +83,117 @@ class DeviceController extends BaseController
$params["gets"] = [
'serial_no' => $serialNo,
'mac' => $mac,
+ 'project' => $project,
+ 'model' => $model,
+ 'device_id' => $deviceId,
+ 'production' => $production,
+ 'manufacture' => $manufacture,
+ 'status' => $status
];
-
return $this->render('index', $params);
}
/**
+ * @return string
+ */
+ public function actionCreateDevice()
+ {
+ return $this->render('createDevice');
+ }
+
+ /**
+ *
+ */
+ public function actionDoCreateDevice()
+ {
+ $req = Yii::$app->request;
+ $manufactureId = $req->post('manufactureId');
+ $projectId = $req->post('projectId');
+ $modelId = $req->post('modelId');
+ $productionId = $req->post('productionId');
+
+ $manufactureNo = $req->post('manufactureNo');
+ $projectNo = $req->post('projectNo');
+ $modelNo = $req->post('modelNo');
+ $productionNo = $req->post('productionNo');
+
+ $num = $req->post('num');
+ $e = new stdClass();
+ $e->success = false;
+ $e->message = 'fail';
+ if (empty($num)) {
+ $e->message = '数量不能为0';
+ return $this->renderJson($e);
+ }
+ if (1 * $num > 30000) {
+ $e->message = '数量不能超过3万0';
+ return $this->renderJson($e);
+ }
+
+ $batchNo = strtoupper(Device::getBatchNo($manufactureNo,$projectNo,$modelNo,$productionNo));
+ $batchModel = CreateBatchRepository::findOne(['batch_no' => $batchNo]);
+ if ($batchModel) {
+ $e->message = '已经创建过这个批次序列号';
+ return $this->renderJson($e);
+ }
+
+ $item = [
+ 'batch_no' => $batchNo,
+ 'manufacture_id' => $manufactureId,
+ 'project_id' => $projectId,
+ 'model_id' => $modelId,
+ 'num' => $num,
+ 'production_id' => $productionId,
+ ];
+ $transaction = Yii::$app->db->beginTransaction();
+ try {
+ $newBatchModel = CreateBatch::create($item);
+ $saveData = [];
+ $tt = time();
+ for ($i = 1 ; $i <= $num; $i++) {
+ $saveData[] = [
+ strtoupper($batchNo.sprintf('%04x', $i)),
+ Utils::macGenerate(),
+ 0,
+ $newBatchModel->id,
+ 0,
+ 0,
+ 0,
+ 0,
+ $tt,
+ $tt
+ ];
+
+ }
+ $res = Yii::$app->db->createCommand()->batchInsert(DeviceModel::tableName(),
+ array('serial_no','mac','status','batch_id','is_delete','has_re_auth','apply_at','auth_at','created_at','updated_at'),
+ $saveData)->execute();//执行批量添加
+ $transaction->commit();
+ $e->success = true;
+ } catch (Exception $exception) {
+ $transaction->rollBack();
+ $e->message = '创建失败';
+ }
+
+ return $this->renderJson($e);
+ }
+
+ /**
+ * @return string
+ */
+ public function actionSearchItem()
+ {
+ $req = Yii::$app->request;
+ $type = $req->post('type');
+ $keyword = $req->post('query');
+ $e = new stdClass();
+ $list = CreateBatchRepository::getSerialNoComponent($type, $keyword);
+ $e->list = $list;
+
+ return $this->renderJson($e);
+ }
+ /**
* 导出订单数据
* @return string
*/
@@ -67,10 +206,67 @@ class DeviceController extends BaseController
/**
* @return string
*/
- public function actionInfo()
+ public function actionAuthDevice()
{
+ $req = Yii::$app->request;
+ $id = $req->post('id');
+ $e = new stdClass();
+ $e->success = false;
+ $e->message = 'fail';
+ $deviceModel = DeviceRepository::findOne(['id' => $id]);
+ if (empty($deviceModel)) {
+ $e->message = '找不到该设备';
+ return $this->renderJson($e);
+ }
+ if(DeviceStatus::HAS_AUTH == $deviceModel->status) {
+ $e->message = '设备已经授权了';
+ return $this->renderJson($e);
+ }
+ if (empty($deviceModel->device_id)) {
+ $e->message = '设备ID为空,不能授权';
+ return $this->renderJson($e);
+ }
+ $tt = time();
+ $deviceModel->apply_at = $tt;
+ $deviceModel->auth_at = $tt;
+ $deviceModel->status = DeviceStatus::HAS_AUTH;
+ $result = $deviceModel->save();
+ if ($result) {
+ $e->success = true;
+ } else {
+ $e->message = '授权失败';
+ }
+ return $this->renderJson($e);
}
+ /**
+ * @return string
+ */
+ public function actionDelDevice()
+ {
+ $req = Yii::$app->request;
+ $id = $req->post('id');
+ $e = new stdClass();
+ $e->success = false;
+ $e->message = 'fail';
+ $deviceModel = DeviceRepository::findOne(['id' => $id]);
+ if (empty($deviceModel)) {
+ $e->message = '找不到该设备';
+ return $this->renderJson($e);
+ }
+
+ $tt = time();
+
+ $deviceModel->is_delete = 1;
+ $result = $deviceModel->save();
+ if ($result) {
+ $e->success = true;
+ } else {
+ $e->message = '删除失败';
+ }
+
+ return $this->renderJson($e);
+ }
}
\ No newline at end of file
diff --git a/app-ht/modules/device/views/device/createDevice.php b/app-ht/modules/device/views/device/createDevice.php
new file mode 100644
index 0000000..a936a90
--- /dev/null
+++ b/app-ht/modules/device/views/device/createDevice.php
@@ -0,0 +1,138 @@
+title = '新建序列号';
+$this->params['breadcrumbs'][] = '序列号管理';
+$this->params['breadcrumbs'][] = ['label' => '序列号列表', 'url' => ['/device/deivce/index']];
+$this->params['breadcrumbs'][] = $this->title;
+
+CssFiles::register($this, 'exts/showimg/css/showimg.css');
+
+?>
+
+
+
+
+
diff --git a/app-ht/modules/device/views/device/index.php b/app-ht/modules/device/views/device/index.php
index 04a43e4..7764ea6 100644
--- a/app-ht/modules/device/views/device/index.php
+++ b/app-ht/modules/device/views/device/index.php
@@ -1,35 +1,85 @@
title = '序列号管理';
$this->params['breadcrumbs'][] = '序列号管理';
$this->params['breadcrumbs'][] = $this->title;
?>
-
+
@@ -40,18 +90,17 @@ $this->params['breadcrumbs'][] = $this->title;
ID |
- 序列号 |
+ 序列号 |
厂商 |
- 项目 |
-
+ 项目 |
设备型号 |
- 生产日期 |
- MAC地址 |
- 设备ID |
- 申请时间 |
- 授权时间 |
- 状态 |
- 操作 |
+ 生产日期 |
+ MAC地址 |
+ 设备ID |
+ 申请时间 |
+ 授权时间 |
+ 状态 |
+ 操作 |
@@ -59,42 +108,42 @@ $this->params['breadcrumbs'][] = $this->title;
-
+ |
= $item['id'] ?>
|
-
- = $item['serial_no'] ?>
+ |
+ = $item['serial_no'] ?>
|
-
+ |
= $item['manufacture'] ?>
|
-
+ |
= $item['project'] ?>
|
-
+ |
= $item['model'] ?>
|
-
+ |
= $item['production'] ?>
|
-
- = $item['mac'] ?>
+ |
+ = $item['mac'] ?>
|
-
- = $item['device_id'] ?>
+ |
+ = $item['device_id']? $item['device_id']:'暂无'?>
|
-
- = date('Y-m-d H:i:s',$item['apply_at'] ) ?>
+ |
+ = $item['apply_at']?date('Y-m-d H:i:s', $item['apply_at']):'暂无' ?>
|
-
- = date('Y-m-d H:i:s',$item['auth_at'] ) ?>
+ |
+ = $item['auth_at']? date('Y-m-d H:i:s', $item['auth_at']):'暂无' ?>
|
-
+ |
= $statusList[$item['status']] ?>
|
-
- |
- |
+ |
+ |
+ |
|
@@ -119,8 +168,35 @@ $this->params['breadcrumbs'][] = $this->title;
+
\ No newline at end of file
diff --git a/common/helpers/Utils.php b/common/helpers/Utils.php
index b526986..b37ce2a 100644
--- a/common/helpers/Utils.php
+++ b/common/helpers/Utils.php
@@ -523,20 +523,8 @@ class Utils
* 生成mac 地址
* @return string
*/
- static function macGenerate() {
- // 第二位必须是偶数
- /*
- $rArray = [
- 0x1C,
- 0x1C,
- 0x1C,
- mt_rand(0x00, 0x7f),
- mt_rand(0x00, 0xff),
- mt_rand(0x00, 0xff)
- ];
- return implode(':', array_map(function($v) {
- return sprintf("%02X", $v);
- }, $rArray));*/
+ static function macGenerate()
+ {
$adrArray = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" ];
$returnMAC = [];
@@ -547,7 +535,7 @@ class Utils
} else {
//第二位只能是偶数
$indexArray = [1, 3, 5, 7, 9, 11, 13, 15];
- $index = $indexArray[mt_rand(1, 8)];
+ $index = $indexArray[mt_rand(0, 7)];
}
$returnMAC[] = $adrArray[$index];
diff --git a/console/controllers/TestController.php b/console/controllers/TestController.php
index 9ec2b05..b48f65c 100644
--- a/console/controllers/TestController.php
+++ b/console/controllers/TestController.php
@@ -72,662 +72,10 @@ use yii\helpers\ArrayHelper;
class TestController extends Controller
{
- public function actionCallT()
- {
- //设备报修:22.552092, 113.927124, 工程师 ,
- //echo Distance::getDistance(22.561575,113.891098, 22.554621,113.906006);
- echo "start";
- echo (null !== '0');
- echo "end";
-
- //
- $mailList = array('xukexuzhun1@163.com', 'perelmen@qq.com');
-
- /*
- foreach ($mailList as $mail) {
- $emailSendHandle = \yii::$app->invoice_mailer->compose();
- $emailSendHandle->setTo($mail);
- $emailSendHandle->setTextBody('深圳下大雨了 delete');
- $emailSendHandle->setSubject('深圳下大雨了 subject ....');
- $result = $emailSendHandle->send();
-
- echo $result ."\r\n";
- }
- */
- //$str = "2018-09-04 09:00:00";
- //$result = DeviceSearch::splitText('[沧田中]税]x金典');
- //print_r($result);
- //echo round('33.1',0);
-
- //echo Deduction::coverInt(0.9);
-
- //$returnArr = Deduction::randomUserTag(9, 4);
- //shuffle($returnArr);
- //print_r($returnArr);
- //echo sprintf('%d', 2.00);
-
- }
-
-
-
-
- public function actionBindPhone()
- {
- $numbers = PrivateNumber::getAllPrivateNumbers();
- $result = PrivateNumber::bindNumber( '17724017057','17004894899');
- //echo PrivateNumber::$postResponseStr;
- echo "\r\n";
- echo $result;
- }
-
- public function actionBatchBindPhone()
- {
- $query = new Query();
- $query->from("jwx_engineer");
- $query->select("id, mobile");
- $query->offset(0);
- $query->orderBy("id asc");
- $query->limit(810);
- $engineers = $query->all();
-
- $engineerLen = count($engineers);
- $pair = (int)$engineerLen /2;
-
- $st = time();
- echo 'start:'.$st;
- echo "\r\n";
- $redis = \yii::$app->redis;
- $count = 0;
- for($i = 0; $i < $pair; $i++) {
- $j = $pair + $i;
- $rKey = 'mobile_'.$engineers[$i]['mobile']."__". $engineers[$j]['mobile'];
- //$redis->del($rKey);
- $result = PrivateNumber::bindNumber($engineers[$i]['mobile'], $engineers[$j]['mobile']);
- //$redis->set($rKey,$result);
- $resultJson = json_decode($result);
- if ( '000000' == $resultJson->code) {
- $count++;
- }
- echo $rKey;
- echo $result ."\r\n";
-
- }
- echo "pair:".$pair;
- echo "\r\n";
- $et = time();
- echo 'end:'.$et;
- echo "\r\n";
- echo "t:".($et - $st);
- echo "\r\n";
- echo "ok:".$count;
- echo "\r\n";
- }
- public function actionBatchUnbindPhone()
- {
- $ids = [269,301,314,316,320,322,330,339,344,345,350,369,378,380];
- $privateNumberRecordModel = PrivateNumberBindRecord::find();
- $privateNumberRecordModel->where(['id' => $ids]);
- $privateNumberRecordModel->asArray();
- $records = $privateNumberRecordModel->all();
- $tt = time();
- foreach($records as $record){
- $recordModel = PrivateNumberBindRecord::findOne($record['id']);
- if($recordModel) {
- //$result = PrivateNumber::unbindNumber($record['subscription_id'], 2);
- //echo $result. "\r\n";
- //$recordModel->status = 0;
- //$recordModel->is_main = 2;
- $recordModel->unbind_at = $tt;
- $recordModel->unbind_desc = '超时手动解绑';
- $result2 = $recordModel->save();
- echo "result:". $result2. '__';
-
- echo $recordModel->subscription_id. "\r\n";
-
- }
- }
- }
- public function actionAna()
- {
- $redis = \yii::$app->redis;
- $records = $redis->hgetall('mobile*');
- print_r($records);
- }
-
- public function actionUnbindPhone()
- {
- $subscriptionId = '17150372466'; //8617150372466 17150372300
- $result = PrivateNumber::unbindNumber($subscriptionId, 1);
- //echo PrivateNumber::$postResponseStr;
- echo "\r\n";
- echo $result;
-
- }
-
- public function actionQueryPhone()
- {
- $numbers = PrivateNumber::getAllPrivateNumbers();
- $result = PrivateNumber::queryOrderedNumber('17150372300');
- echo $result;
- }
-
- public function actionQueryVoiceRecord()
- {
- $subscribeId = '66053756068216559371537933854093';
- $st = PrivateNumber::coverTimeStampToPHP('2018-09-26T03:46:07Z');
- $ed = PrivateNumber::coverTimeStampToPHP('2018-09-26T06:49:01Z');
- $result = PrivateNumber::queryVoiceRecord('fa2b53fb-2a95-49e5-9a5d-9f2b403a8295', '2018-09-26 14:30:00','2018-09-26 14:50:00');
- echo $result;
- }
-
- public function actionGetVoice()
- {
- $arr = ['66261453769654176011542769693114'];
- $privateModel = PrivateNumberVoice::find();
- $privateModel->where(['call_identifier' => $arr]);
- $privateModel->asArray();
- $voiceArr = $privateModel->all();
- foreach($voiceArr as $k=>$v){
- $call_id = $v['call_identifier'];
- echo $v['path']."\r\n";
- $result = PrivateNumber::getRecordDownloadURL($call_id);
-
- $path = \yii::getAlias('@app/runtime') . "/empty/".$call_id.".wav";
-
- $local_file = fopen($path, 'w');
- if (false !== $local_file){
- if (false !== fwrite($local_file, $result)) {
- fclose($local_file);
- $savePath = $v['path'];
- FileManager::add($path , $savePath);
- }
- }
- }
- }
-
- public function actionAddOssFile()
- {
- $file = '/s201812211218389859.pdf';
- $path = \yii::getAlias('@app/runtime') . $file ;
- $ossSavePath = 'invoice/20181221/s201812211218389859.pdf';
- FileManager::add($path , $ossSavePath);
- echo "end";
- }
-
- public function actionTestCall()
- {
- //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::bindNumber('15622137119', '15999944931');
- //{"Message":"OK","RequestId":"1EE31873-4053-44F5-B2B4-031ECC4671F7","Code":"OK","SecretBindDTO":{"Extension":"15999944931","SecretNo":"13143439849","SubsId":"974715743568877041"}
- //echo json_encode($result);
- echo "\r\n";
-
- //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::unbindSubscription('974715743568877041', '13143439849');
- //echo json_encode($result);
-
- //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::querySubscriptionDetail('134915943835832737', '17097534251');
- //echo json_encode($result, JSON_UNESCAPED_UNICODE);echo "\r\n";
-
-
- //$result = \common\exts\Aliyun\DYPLS\PrivateNumber::queryRecordFileDownloadUrl("415c0511041a2151", date('Y-m-d H:i:s', 1543835908));
- //echo json_encode($result, JSON_UNESCAPED_UNICODE);echo "\r\n";
- //{"Message":"OK","RequestId":"7CFD87F7-1FA9-4EFE-BBCA-CCF4CB6F1FD4","DownloadUrl":"http:\/\/secret-axb-record-files.oss-cn-shanghai.aliyuncs.com\/134915943835832737_415c0511041a2151.mp3?Expires=1543843500&OSSAccessKeyId=LTAI27GqAW1VrcQA&Signature=eEATuKSQDIxUurnSuqghV09D3yE%3D","Code":"OK"}
- }
-
- public function actionDeduction()
- {
- $repairOrderModel = RepairOrder::findOne(['uuid' => '4ba0976b7a0d3d16ae1de634a6201134']);
- $activityModel = DeductionActivityRepository::getCurrentActivity();
- $repairOrderDeduction = RepairOrderDeduction::findOne([
- 'repair_order_id' => $repairOrderModel->id,
- 'activity_id' => $activityModel->id,
- ]);
-
- $expireTime = $activityModel->expired_time;
- $re = Deduction::canDeduction($repairOrderDeduction, $repairOrderModel, $expireTime);
- Deduction::setRiseVale($repairOrderModel, $expireTime);
- if (0 == $re->errCode) {
- echo $re->error."--1\r\n";
- return ;
- }
- $saveData = ['userTagId' => rand(1,4)];
- $clientUserId = 8;
- $addResult = Deduction::addDeductionAmount($activityModel, $repairOrderModel, $clientUserId, $saveData);
- echo $addResult->error."\r\n";
- }
-
- /**
- * 初始化5元抵扣券
- */
- public function actionAddDe()
- {
- $repairOrderModel = RepairOrder::findOne(['uuid' => '4ba0976b7a0d3d16ae1de634a6201134']);
- $activityModel = DeductionActivityRepository::getCurrentActivity();
-
- $result = Deduction::initOrderDeduction($repairOrderModel, $activityModel->uuid);
- if (1 == $result->errCode) {
- echo "add ok\r\n";
- } else {
- echo $result->error."\r\n";
- }
- Deduction::getActivityInfoByOrderUUId('4ba0976b7a0d3d16ae1de634a6201134s');
- }
-
- public function actionGetFriends()
- {
- $result = Deduction::getRecords('9a4ba1dcae263f11893e707d733e3593', 4, 0);
- print_r($result);
- }
-
- public function actionDeductionPage()
- {
- $orderUUId = '';//$this->request->post('id');
- $e = new \stdClass();
- $e->success = true;
- $e->canClick = true;
- $e->selectedTagId = '';
- $e->clickResult = 0;
- $batchInfo = Deduction::getBatchInfoByOrderUUId($orderUUId);
- $orderModel = $batchInfo['orderModel'];
- $repairOrderDeduction = $batchInfo['repairOrderDeduction'];
- $deductionActivity = $batchInfo['deductionActivity'];
- //$userId = $this->getUserId();
- $clientUserId = 15;//$this->getClientUserId();
-
- $expireTime = $deductionActivity->expired_time;
- $re = Deduction::canDeduction($repairOrderDeduction, $orderModel, $expireTime);
- if (0 == $re->errCode) {
- $e->canClick = false;
- $e->error = $re->error;
- }
- $checkResult = Deduction::hasClickDeduction($repairOrderDeduction, $orderModel, $clientUserId);
- if (0 == $checkResult->errCode) {
- $e->canClick = false;
- $e->selectedTagId = $checkResult->selectedTag;
- $e->clickResult = Deduction::coverInt($checkResult->clickResult);
- $e->error = $re->error;
- }
- if (isset($deductionActivity['share_img'])) {
- $deductionActivity['share_img'] = ImageManager::getUrl($deductionActivity['share_img']);
- }
- $e->shareTitle = isset($deductionActivity['share_title'])? $deductionActivity['share_title']: '帮我砍价';
- $e->shareImg = $deductionActivity['share_img'];
- $e->userTagList = Deduction::randomUserTag(9, $e->selectedTagId);
- return $e;
- }
-
- public function actionSendMina()
- {
- $str = 'M,,';
- $pattern = "/^[A-Z](,[A-Z])+?$/";
- //$pattern = "/^[A-Z]$/";
- $rs = preg_match($pattern, $str);
- print_r($rs);
- }
- public function actionPEngineer()
- {
- //echo Utils::hidePhoneNumber('15622137119');
-
- }
-
- public function actionWebSocket()
- {
- $to_uid = "123";
- // 推送的url地址,使用自己的服务器地址
- $push_api_url = "http://192.168.0.106:20211/";
- global $argv;
- $toId = isset($argv[2])?$argv[2]:'';
- $content = isset($argv[3])?$argv[3]:'test ing';
-
- $newPost = [];
- $newPost['username'] = '张小小';
- $newPost['message'] = $content;
-
- $post_data = array(
- "type" => "publish",
- "content" => json_encode($newPost),
- "to" => $toId,
- );
- Http::post($push_api_url, $post_data);
- }
-
-
- public function actionSub()
- {
- $sTime = time();
- echo "== start time 导入数据 == \r\n";
- $startTime = strtotime('2019-01-01');
- $endTime = strtotime(date('Y-m-d'));
- for ($i = 0 ;$startTime < $endTime ; $i++) {
- if ($i == 29) {
- break;
- }
- $startTime = $startTime + (24 * 3600);
- $isTime = time();
- EngineerTask::archiveAchievement($startTime, false);
- $ieTime = time();
- $sec = $ieTime - $isTime;
- echo "date:".date('Y-m-d', $startTime) .' cost time:'. $sec ."\r\n";
- }
-
- }
-
-
- public function actionSt()
- {
- $orders = $this->getOrdersInfo();
- $prefers = $this->getPreferList();
-
- $round0 = 0;
- $firstRound = 0;
- $secondRound = 0;
- $thriRound = 0;
- $round4 = 0;
- $round5 = 0;
- $round6 = 0;
- $round7 = 0;
- $dispatchCount = 0;
- $onSiteCount = 0;
- $normalCount = 0;
- foreach ($orders as $k => $order) {
- $engineerIds = $prefers['user_id_'.$order['user_id']];
- $dispatchRecordsModel = RepairOrderDispatchRecords::find();
- $dispatchRecordsModel->where(['repair_order_id' => $order['id'] ]);
- $dispatchRecordsModel->asArray();
- $findResult = $dispatchRecordsModel->all();
- $dispatchCount = $dispatchCount + count($findResult);
- echo $order['id'].' ccccount:'.count($findResult)."----\r\n";
- if (empty($findResult)) {
- $onSiteCount ++;
- } else {
- $normalCount++;
- }
- if (empty($findResult)) {
- continue;
- }
- $orderFlag = 0;
- foreach ($findResult as $kk => $vv) {
- if (0 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $round0++;
- $orderFlag = true;
- }
- if (1 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $firstRound++;$orderFlag = true;
- }
- if (2 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $secondRound++;$orderFlag = true;
- }
- if (3 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $thriRound++;$orderFlag = true;
- }
- if (4 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $round4++;$orderFlag = true;
- }
- if (5 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $round5++;$orderFlag = true;
- }
- if (6 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $round6++;$orderFlag = true;
- }
- if (7 == $vv['dispatch_round'] && in_array($vv['engineer_id'], $engineerIds)) {
- $round7++;$orderFlag = true;
- }
- }
- if (false == $orderFlag ) {
- echo "null:".$order['id']."\r\n";
- }
- }
- echo "dispatchCount:".$dispatchCount."\r\n";
- echo "onSiteCount:".$onSiteCount.' normalCount:'.$normalCount."\r\n";
- echo $round0.'_'.$firstRound.'_'.$secondRound.'_'.$thriRound.'_'.$round4.'_'.$round5.'_'.$round6.'_'.$round7;
- }
-
-
- /**
- * 临时提交电子发票申请
- * @return string
- */
- public function actionCreateInvoice()
- {
- $orderModel = RepairOrder::findOne(['order_no' => '201904241505438057' ]);
- if (empty($orderModel)) {
- echo "open invoice fail: repair order is null ";
- return false;
- }
- // 只是开一单一票
- $info = [
- 'user_id' => $orderModel->user_id,
- 'type' => Invoice::HEAD_TYPE_COMPANY,
- 'head' => '深圳市星康科技有限公司',
- 'taxpayer_id_number' => '91440300319568546J',
- 'email' => 'perelmen@qq.com',
- 'remark' => '订单号:201904241505438057',
- 'register_address' => '',
- 'register_tel' => '',
- 'bank' => '',
- 'bank_account' => '',
- 'amount' => 329.20,
- 'selectOrders' => [$orderModel->uuid]
- ];
- $result = \domain\trade\Invoice::createInvoice($info);
- echo json_encode($result);
- }
-
- /**
- * 直接开票,不要用记录到数据库里面,有些商品要开票,直接开票发送总局软件那里,
- * 先发邮件到自己邮箱再发pdf 给客户
- */
- public function actionInvoiceStraight()
- {
- $amount = 20; //开票金额
- $sid = 'sg'.date('YmdHis').mt_rand(1000,9999);
- $customerInfo = array(
- 'ghdwsbh' => '', //公司纳税人识别码
- 'ghdwmc' => '许可', //抬头
- 'email' => 'perelmen@qq.com',
- 'ghdwdzdh' => '', //'购货单位地址、电话'
- 'ghdwyhzh' => '', //'购货单位开户行、银行帐号'
- 'bz' => 'A4纸1箱' //备注
- );
- $serviceInfo = InvoiceApi::getGoodsCode(InvoiceApi::A4_PAPER_INVOICE);
- $queryResult = InvoiceApi::makeOutAnInvoice($sid, $amount, $serviceInfo, $customerInfo);
- var_dump($queryResult);
- sleep(4);
- echo "query1:";
- $queryResult = InvoiceApi::queryInvoice($sid);
- var_dump($queryResult);
- sleep(5);
- echo "query2:";
- $queryResult = InvoiceApi::queryInvoice($sid);
- var_dump($queryResult);
- echo "end";
-
- }
-
- public function actionExportD()
- {
- $postId = date('Ymd0001');
- $query = new Query();
- $query->select("repair_order.order_no,repair_order.repair_device_name as device, GROUP_CONCAT(device_fault.`name`) as faults,
-
- parent_device_cat.name as keyword,
- brand.chinese_name as brand");
- $query->from("repair_order_repair_plans");
- $query->leftJoin("repair_order","repair_order.id = repair_order_repair_plans.repair_order_id and repair_order.repair_device_type = 1");
- $query->leftJoin("repair_order_detail","repair_order_detail.repair_order_id = repair_order_repair_plans.repair_order_id and repair_order_detail.pay_at > 0");
- $query->leftJoin("repair_plan","repair_plan.id = repair_order_repair_plans.repair_plan_id");
- $query->leftJoin("device_fault","device_fault.id = repair_plan.device_fault_id");
- $query->leftJoin("engineer_profile","engineer_profile.engineer_id = repair_order.engineer_id");
-
- $query->leftJoin("user_device","user_device.id = repair_order.repair_device_id");
- $query->leftJoin("device","device.id = user_device.device_id");
- $query->leftJoin("model","model.id = device.model_id");
- $query->leftJoin("brand","brand.id = model.brand_id");
- $query->leftJoin("device_cat","device_cat.id = device.device_cat_id");
- $query->leftJoin("device_cat as parent_device_cat","parent_device_cat.id = device_cat.parent_id");
- $query->where("repair_order.is_system_delete = 0 and repair_order.pay_price > 0 and repair_order.repair_device_type = 1");
- $query->andWhere("repair_order.created_at > UNIX_TIMESTAMP('2019-01-01')");
- //$query->limit(3);
- $query->groupBy("repair_order.order_no");
- $items = $query->all();
-
- $totalCount = count($items);
- $postItemsTmp = [];
- foreach($items as $k => $item) {
- unset($item['order_no']);
- $key = $item['device'].'_'.$item['faults'].'_'.$item['keyword'].'_'.$item['brand'];
- $postItemsTmp[$key] = $item;
- }
- $postItems = [];
- foreach($postItemsTmp as $k => $vv) {
- $vv['keyword'] = $vv['keyword'].'维修';
- $postItems[] = $vv;
- }
-
- $dataStr = [
- "items" => $postItems,
- "attribute" => [ "count" => $totalCount, "totalcount" => $totalCount, "id" => $postId, "seq" => 0]
- ];
-
- $postDataStr = json_encode($dataStr, JSON_UNESCAPED_UNICODE);
- $postDataStr = str_replace('\/', '/', $postDataStr);
-
- $postData = [
- "data" => $postDataStr,
- "lifespan" => 86400,
- "query" => "{\"type\":1000078}",
- "scene" => 1
- ];
- echo json_encode($postData, JSON_UNESCAPED_UNICODE);
-
- }
-
- public function actionTV()
- {
- $repairOrderModel = RepairOrder::find();
- $repairOrderModel->alias('ro');
- $repairOrderModel->select('count(*) as cc,GROUP_CONCAT(ro.created_at) as cr, ro.repair_device_id');
- $repairOrderModel->leftJoin('repair_order_detail rod', 'rod.repair_order_id = ro.id');
- $repairOrderModel->where('ro.repair_device_type = 1 and rod.pay_at >0 and ro.is_system_delete = 0');
- $repairOrderModel->groupBy('ro.repair_device_id');
- $repairOrderModel->having('cc >=2');
- $repairOrderModel->asArray();
- $repairOrderArr = $repairOrderModel->all();
- //print_r($repairOrderArr);
- foreach($repairOrderArr as $k => $order) {
- $timeArr = explode(',', $order['cr']);
- sort($timeArr);
- $timeDuration = [];
- foreach($timeArr as $kk => $vv) {
- if (isset($timeArr[$kk + 1])) {
- $durationSecond = 0 - ($vv - $timeArr[$kk + 1]);
-
- if ($durationSecond<60) {
- $sDur = $durationSecond. '秒';
- } elseif($durationSecond >= 60 && $durationSecond < 3600) {
- $sDur = (round($durationSecond /60, 1)). '分';
- } elseif($durationSecond >= 3600 && $durationSecond < 86400){
- $sDur = (round($durationSecond /3600, 1)). '时';
- } elseif($durationSecond >= 86400 && $durationSecond < 604800) {
- $sDur = (round($durationSecond /(3600*24), 1)). '天';
- } else {
- $sDur = (round($durationSecond /(3600*24*7), 1)). '周';
- }
- $timeDuration[] = $sDur;
- }
- }
- $order['durations'] = implode(',', $timeDuration);
- $repairOrderArr[$k] = $order;
- //echo $order['cc'].'_'.$order['repair_device_id'].'_'.$order['durations']."\r\n";
- }
-
- $arr = [19,39,40];
- sort($arr);
- print_r($arr);
-
- }
-
- public function actionSetPostData()
- {
- $str = '';
-
- $postPackageId = 'D'.date('Ymd').'0000001';
- $postPackage = [
- "lifespan" => 86400,
- "query" => "{\"type\":1000078}",
- "scene" => 1,
- "data" => "",
- ];
-
- $packageAttribute = [
- "count" => '',
- "totalcount" => 100,
- "id" => $postPackageId,
- "seq" => 0
-
- ];
-
- $index = 0;
- $keywords = ["打印机维修","复印机维修","电脑维修","Mac电脑维修","加碳粉","换墨盒","重装系统","上门维修打印机","上门维修电脑","上门维修复印机","电脑蓝屏","无法使用扫描","打印机无法开机","无法打印","打印效果差","打印卡纸","设备未共享","设备未安装","缺粉","打印颜色淡","打印不清晰","打印模糊","传真或扫描模糊","纸张进纸故障","无法上纸","换主板","换内存","色带用尽","键盘损坏","触摸板失灵","电池鼓包","电池不耐用","无法充电","风扇噪音大","屏幕外壳变形","设备无法开机","无法使用传真","墨水不足","屏幕按键失灵","外壳磨损变形","内屏损坏无显示","闪屏","花屏","碎屏","USB无法使用","上门安装电脑","黑屏","安装软件","安装驱动","无法上网","运行速度慢","忘记系统密码","无法登陆系统","无法连接投影仪","未知故障","复印效果差","无法发送邮件","无法共享打印机","无法打开文件","提示C盘空间不足","办公软件无法使用","无法使用拼音","浏览器无法播放视频","电脑中毒","键盘按键无反应","无法打开office文件","深圳修电脑","深圳修打印机","深圳修复印机","加墨水","福田修电脑","福田修打印机","福田修复印机","修佳能打印机","修惠普打印机","修京瓷打印机","修联想笔记本","修苹果笔记本","修爱普生打印机","喷墨打印机维修","换打印纸","维修三星打印机","针式打印机维修","激光打印机维修","喷墨打印机维修","黑白打印机维修","彩色复印维修","漏墨","复印机闪灯","复印无法联网"];
- $pageList = [];
- foreach($keywords as $k => $v) {
- $pageList[] = ["keyword" => $v];
- }
- $totalcount = count($keywords);
- $postRound = 0;
-
- //"attribute" => [
- $packageAttribute['count'] = $totalcount;
- $packageAttribute['totalcount'] = $totalcount;
- $packageAttribute['seq'] = $postRound;
-
- $postPackage['data'] = json_encode(["items" => $pageList, "attribute" => $packageAttribute], JSON_UNESCAPED_UNICODE);
- $postPackage['data'] = str_replace('\/', '/', $postPackage['data']);
- $postWxStr = json_encode($postPackage, JSON_UNESCAPED_UNICODE);
- echo $postWxStr;
- echo "\r\n";
- $minaWechat = MinaHelper::getWxPHPSDK();
- $result = $minaWechat->setDynamicData($postWxStr);
- print_r($result);
- echo $minaWechat->errCode."\r\n";
- echo $minaWechat->errMsg;
- echo "\r\n";
-
- }
-
- /**
- * 贴码补贴发放
- * @return bool
- */
- public function actionPasteAward()
- {
- $bindDeviceApplyFind = BindDeviceApply::find();
- $bindDeviceApplyFind->where("apply_at > UNIX_TIMESTAMP('2019-08-01') and apply_at <= UNIX_TIMESTAMP('2019-08-21') and status = 1 and id = 209227");
- $applyArr = $bindDeviceApplyFind->all();
- foreach ($applyArr as $k => $apply) {
- $engineerModel = Engineer::findOne(['id' => $apply->engineer_id]);
- $result = ApplyAwardRule::canReceivePasteAward($apply, $engineerModel);
- //AppLog::DEBUG('= engineerAddPasteAward =result:'.$result);
- if ($result) {
- $addR = ApplyAwardRule::addPasteAward($apply, strtotime('2019-08-10 00:00:54'));
- return $addR;
- }
- }
- }
- public function actionUserConfirmPrice()
- {
- $orderModel = RepairOrderRepository::findOne(['uuid' => '72c7fd2bb0003bcf8bd55caf3a90ab7b']);
- $userId = $orderModel->user_id;
- $success = PrivateOrderUserOp::confirmPrice($orderModel, $userId, 0, 0);
- echo 'end';
- }
-
- public function actionClearLog()
- {
- $str = 'OKI 打印机';
- $splitResult = DeviceSearch::splitText($str);
- print_r($splitResult);
- }
-
+ public function actionGen()
+ {
+ echo sprintf('%04x', 1);
+ }
}
diff --git a/domain/Device.php b/domain/Device.php
deleted file mode 100644
index b9c0b1c..0000000
--- a/domain/Device.php
+++ /dev/null
@@ -1,9 +0,0 @@
-where($where);
- $deviceFind->asArray();
- if ($offset) {
- $deviceFind->offset($offset);
- }
- if ($limit) {
- $deviceFind->limit($limit);
- }
- $all = $deviceFind->all();
-
- return $all;
- }
-
- /**
- * @param $where
- * @return int|string
- */
- static function getListCount($where)
- {
- $deviceFind = DeviceModel::find();
- $deviceFind->where($where);
- $all = $deviceFind->count();
-
- return $all;
- }
-
- /**
- * @param $id
- * @return null|static
- */
- static function selectOne($id)
- {
- return DeviceModel::findOne($id);
- }
-}
\ No newline at end of file
diff --git a/domain/DeviceStatus.php b/domain/DeviceStatus.php
deleted file mode 100644
index 7c0b6ca..0000000
--- a/domain/DeviceStatus.php
+++ /dev/null
@@ -1,33 +0,0 @@
- '未授权',
- self::HAS_AUTH => '已授权',
- self::FAIL_AUTH => '授权失败',
- ];
- if ('' === $index) {
- return $arr;
- }
-
- if (isset($arr[$index])) {
- return $arr[$index];
- } else {
- return '';
- }
- }
-}
\ No newline at end of file
diff --git a/domain/device/CreateBatch.php b/domain/device/CreateBatch.php
new file mode 100644
index 0000000..d48eccf
--- /dev/null
+++ b/domain/device/CreateBatch.php
@@ -0,0 +1,32 @@
+ CreateBatchModel::className(),
+ 'batch_no' => $item['batch_no'],
+ 'manufacture_id' => $item['manufacture_id'],
+ 'project_id' => $item['project_id'],
+ 'model_id' => $item['model_id'],
+ 'num' => $item['num'],
+ 'production_id' => $item['production_id'],
+ ]);
+ if ($createBatch->save()) {
+ return $createBatch;
+ } else {
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/domain/device/CreateBatchRepository.php b/domain/device/CreateBatchRepository.php
new file mode 100644
index 0000000..1c1d180
--- /dev/null
+++ b/domain/device/CreateBatchRepository.php
@@ -0,0 +1,67 @@
+select('id,manufacture_no, name');
+ $q->from('manufacture');
+ $q->where('name like "%'.$keyword.'%" or manufacture_no like "%'.$keyword.'%"');
+ $q->limit(20);
+ $list = $q->all();
+
+ return $list;
+ } elseif('project' == $type) {
+ $q = new Query();
+ $q->select('id,project_no, name');
+ $q->from('project');
+ $q->where('name like "%'.$keyword.'%" or project_no like "%'.$keyword.'%"');
+ $q->limit(20);
+ $list = $q->all();
+
+ return $list;
+ } elseif ('model' == $type) {
+ $q = new Query();
+ $q->select('id,model_no, name');
+ $q->from('model');
+ $q->where('name like "%'.$keyword.'%" or model_no like "%'.$keyword.'%"');
+ $q->limit(20);
+ $list = $q->all();
+
+ return $list;
+ } elseif ('production' == $type) {
+ $q = new Query();
+ $q->select('id,production_no, name');
+ $q->from('production');
+ $q->where('name like "%'.$keyword.'%" or production_no like "%'.$keyword.'%"');
+ $q->limit(20);
+ $list = $q->all();
+
+ return $list;
+ } else {
+ return [];
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/domain/device/Device.php b/domain/device/Device.php
new file mode 100644
index 0000000..7dd31b3
--- /dev/null
+++ b/domain/device/Device.php
@@ -0,0 +1,78 @@
+success = false;
+ $e->message = '';
+ $e->serial_no = '';
+ $e->mac = '';
+ $tt = time();
+ $batchNo = self::getBatchNo($manufactureNo, $projectNo, $modelNo, $productionNo);
+ $batchModel = CreateBatchRepository::findOne(['batch_no' => $batchNo]);
+ if (empty($batchModel)) {
+ $e->message = '没有该批次';
+ }
+ $count = DeviceRepository::rowsCount(['batch_id' => $batchModel->batch_id, 'is_delete' => 0]);
+ if ($count > $batchModel->num) {
+ // 超过了限制数,记录到另外一个表里面
+ // to do 记录到表里面
+
+ $e->message = '授权失败';
+ return $e;
+ }
+ $deviceModel = DeviceRepository::findOne(['device_id' => $deviceId, 'is_delete' => 0]);
+ if (empty($deviceModel)) {
+ $newDeviceModel = DeviceRepository::findOne(['device_id'=> null, 'is_delete' => 0, 'status' => DeviceStatus::NO_AUTH]);
+ $newDeviceModel->device_id = $deviceId;
+ $newDeviceModel->status = DeviceStatus::HAS_AUTH;
+ $newDeviceModel->apply_at = $tt ;
+ $newDeviceModel->auth_at = $tt;
+ $newDeviceModel->save();
+ $e->message = '授权成功';
+ $e->success = true;
+ $e->serial_no = $newDeviceModel->serial_no;
+ $e->mac = $newDeviceModel->mac;
+
+ return $e;
+ }
+ if (DeviceStatus::HAS_AUTH == $deviceModel->status) {
+ $e->message = '授权成功';
+ $e->success = true;
+ $e->serial_no = $deviceModel->serial_no;
+ $e->mac = $deviceModel->mac;
+ } elseif (DeviceStatus::FAIL_AUTH == $deviceModel->status) {
+ $e->message = '授权失败';
+ } else {
+ $e->message = '授权失败!';
+ }
+
+ return $e;
+ }
+}
\ No newline at end of file
diff --git a/domain/device/DeviceAuthFail.php b/domain/device/DeviceAuthFail.php
new file mode 100644
index 0000000..e9695ee
--- /dev/null
+++ b/domain/device/DeviceAuthFail.php
@@ -0,0 +1,14 @@
+alias('a');
+ $deviceFind->select(['a.*', 'm.name as manufacture','p.name as project','pd.name as production','mo.name as model']);
+ $deviceFind->leftJoin(CreateBatchModel::tableName().' b','b.id = a.batch_id');
+ $deviceFind->leftJoin('manufacture as m', 'm.id = b.manufacture_id');
+ $deviceFind->leftJoin('project as p', 'p.id = b.project_id');
+ $deviceFind->leftJoin('model as mo', 'mo.id = b.model_id');
+ $deviceFind->leftJoin('production as pd', 'pd.id = b.production_id');
+
+ $deviceFind->where($where);
+ $deviceFind->asArray();
+ if ($offset) {
+ $deviceFind->offset($offset);
+ }
+ if ($limit) {
+ $deviceFind->limit($limit);
+ }
+ $all = $deviceFind->all();
+
+ return $all;
+ }
+
+ /**
+ * @param $where
+ * @return int|string
+ */
+ static function getListCount($where)
+ {
+ $deviceFind = DeviceModel::find();
+ $deviceFind->alias('a');
+ $deviceFind->leftJoin(CreateBatchModel::tableName().' b','b.id = a.batch_id');
+ $deviceFind->leftJoin('manufacture as m', 'm.id = b.manufacture_id');
+ $deviceFind->leftJoin('project as p', 'p.id = b.project_id');
+ $deviceFind->leftJoin('model as mo', 'mo.id = b.model_id');
+ $deviceFind->leftJoin('production as pd', 'pd.id = b.production_id');
+ $deviceFind->where($where);
+ $all = $deviceFind->count();
+
+ return $all;
+ }
+
+ /**
+ * @param $condition
+ * @return null|static
+ */
+ static function findOne($condition)
+ {
+ return DeviceModel::findOne($condition);
+ }
+
+ /**
+ * @param $condition
+ * @return array|\yii\db\ActiveRecord[]
+ */
+ static function findAll($condition)
+ {
+ $deviceModel = DeviceModel::find();
+ $deviceModel->where($condition);
+ $list = $deviceModel->all();
+ return $list;
+ }
+
+ /**
+ * @param $condition
+ * @return int|string
+ */
+ static function rowsCount($condition)
+ {
+ $deviceModel = DeviceModel::find();
+ $deviceModel->where($condition);
+ $count = $deviceModel->count();
+ return $count;
+ }
+}
\ No newline at end of file
diff --git a/domain/device/DeviceStatus.php b/domain/device/DeviceStatus.php
new file mode 100644
index 0000000..3f71172
--- /dev/null
+++ b/domain/device/DeviceStatus.php
@@ -0,0 +1,33 @@
+ '未授权',
+ self::HAS_AUTH => '已授权',
+ self::FAIL_AUTH => '授权失败',
+ ];
+ if ('' === $index) {
+ return $arr;
+ }
+
+ if (isset($arr[$index])) {
+ return $arr[$index];
+ } else {
+ return '';
+ }
+ }
+}
\ No newline at end of file
diff --git a/domain/device/models/CreateBatch.php b/domain/device/models/CreateBatch.php
new file mode 100644
index 0000000..a2bd418
--- /dev/null
+++ b/domain/device/models/CreateBatch.php
@@ -0,0 +1,28 @@
+ [
+ 'class' => TimestampBehavior::className(),
+ 'createdAtAttribute' => 'created_at',
+ 'updatedAtAttribute' => 'updated_at',
+ ]
+ ];
+ }
+}
\ No newline at end of file
diff --git a/domain/device/models/Device.php b/domain/device/models/Device.php
new file mode 100644
index 0000000..80fdfbe
--- /dev/null
+++ b/domain/device/models/Device.php
@@ -0,0 +1,37 @@
+ [
+ 'class' => TimestampBehavior::className(),
+ 'createdAtAttribute' => 'created_at',
+ 'updatedAtAttribute' => 'updated_at',
+ ]
+ ];
+ }
+}
\ No newline at end of file
diff --git a/domain/device/models/DeviceAuthFail.php b/domain/device/models/DeviceAuthFail.php
new file mode 100644
index 0000000..a9bb2fd
--- /dev/null
+++ b/domain/device/models/DeviceAuthFail.php
@@ -0,0 +1,28 @@
+ [
+ 'class' => TimestampBehavior::className(),
+ 'createdAtAttribute' => 'created_at',
+ 'updatedAtAttribute' => 'updated_at',
+ ]
+ ];
+ }
+}
\ No newline at end of file
diff --git a/domain/models/Device.php b/domain/models/Device.php
deleted file mode 100644
index fb75bdc..0000000
--- a/domain/models/Device.php
+++ /dev/null
@@ -1,16 +0,0 @@
-