Commit d0653a77 authored by mengweifu's avatar mengweifu

update:ota manage

parent 0df0d809
......@@ -65,7 +65,7 @@ class OtaValidate extends \Validate\BaseValidate
protected function is_label_printer_sn($value){
if( substr($value, 3, 1) != 2 ){
if( substr($value, 3, 1) != '2' ){
return false;
}
return true;
......
......@@ -78,8 +78,10 @@ class OtaService
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if(isset($params['printer_sn']) && $params['printer_sn']) {
if ((new OtaValidate())->is_label_printer_sn($params['printer_sn'])) {
throw new GoodsException(['cus' => GoodsException::PRINTER_SN_ERROR]);
}
$printer = self::list('',$params['printer_sn']);
if ($printer['total'] > 0) {
throw new GoodsException(
['cus' => GoodsException::PRINTER_ALREADY_EXIST,'data'=>[$printer['list'][0]['ota_name']]]
......@@ -88,8 +90,11 @@ class OtaService
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if(isset($params['label_printer_sn']) && $params['label_printer_sn']) {
$printer = self::list('','', '', $params['label_printer_sn']);
if (!(new OtaValidate())->is_label_printer_sn($params['label_printer_sn'])) {
throw new GoodsException(['cus' => GoodsException::PRINTER_SN_ERROR]);
}
$printer = self::list('','', '', $params['label_printer_sn']);
if ($printer['total'] > 0) {
throw new GoodsException(
['cus' => GoodsException::LABEL_PRINTER_ALREADY_EXIST,'data'=>[$printer['list'][0]['ota_name']]]
......@@ -179,7 +184,7 @@ class OtaService
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if(isset($params['printer_sn']) && $params['printer_sn'] && $otaDetail['printer_sn'] != $params['printer_sn']) {
if ((new OtaValidate())->is_label_printer_sn($params['label_printer_sn'])) {
if ((new OtaValidate())->is_label_printer_sn($params['printer_sn'])) {
throw new GoodsException(['cus' => GoodsException::PRINTER_SN_ERROR]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment