Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
e06effd8
Commit
e06effd8
authored
Sep 13, 2021
by
孟维甫
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature_ota_manage' into 'test'
Feature ota manage See merge request bp/goods!47
parents
68a26f4c
0df0d809
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
4 deletions
+80
-4
GoodsException.php
application/exception/custom/GoodsException.php
+2
-0
OtaValidate.php
application/library/Validate/OtaValidate.php
+13
-0
Ota.php
application/modules/Goods/controllers/Ota.php
+12
-0
OtaService.php
application/services/goods/OtaService.php
+53
-4
No files found.
application/exception/custom/GoodsException.php
View file @
e06effd8
...
@@ -18,6 +18,7 @@ class GoodsException extends BaseException
...
@@ -18,6 +18,7 @@ class GoodsException extends BaseException
const
NOT_FIND_MARKETING
=
51
;
const
NOT_FIND_MARKETING
=
51
;
const
LABEL_PRINTER_ALREADY_EXIST
=
53
;
const
LABEL_PRINTER_ALREADY_EXIST
=
53
;
const
PRINTER_BIND_ERROR
=
54
;
const
PRINTER_BIND_ERROR
=
54
;
const
PRINTER_SN_ERROR
=
55
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'商品创建失败,请稍后重试'
,
0
=>
'商品创建失败,请稍后重试'
,
...
@@ -75,5 +76,6 @@ class GoodsException extends BaseException
...
@@ -75,5 +76,6 @@ class GoodsException extends BaseException
52
=>
'过期时间不得小于等于上架开始时间'
,
52
=>
'过期时间不得小于等于上架开始时间'
,
self
::
LABEL_PRINTER_ALREADY_EXIST
=>
'标签打印机已被%s绑定'
,
self
::
LABEL_PRINTER_ALREADY_EXIST
=>
'标签打印机已被%s绑定'
,
self
::
PRINTER_BIND_ERROR
=>
'打印机绑定失败:%s'
,
self
::
PRINTER_BIND_ERROR
=>
'打印机绑定失败:%s'
,
self
::
PRINTER_SN_ERROR
=>
'打印机sn号码有误'
,
];
];
}
}
\ No newline at end of file
application/library/Validate/OtaValidate.php
View file @
e06effd8
...
@@ -49,6 +49,11 @@ class OtaValidate extends \Validate\BaseValidate
...
@@ -49,6 +49,11 @@ class OtaValidate extends \Validate\BaseValidate
return
$this
->
only
([
'ota_id'
]);
return
$this
->
only
([
'ota_id'
]);
}
}
public
function
sceneUndelete
()
{
return
$this
->
only
([
'ota_id'
]);
}
public
function
sceneUpdate
()
public
function
sceneUpdate
()
{
{
return
$this
->
only
([
'ota_id'
,
'ota_name'
,
'address'
,
'longitude'
,
'latitude'
,
'location'
]);
return
$this
->
only
([
'ota_id'
,
'ota_name'
,
'address'
,
'longitude'
,
'latitude'
,
'location'
]);
...
@@ -57,4 +62,12 @@ class OtaValidate extends \Validate\BaseValidate
...
@@ -57,4 +62,12 @@ class OtaValidate extends \Validate\BaseValidate
{
{
return
$this
->
only
([
'ota_id'
]);
return
$this
->
only
([
'ota_id'
]);
}
}
protected
function
is_label_printer_sn
(
$value
){
if
(
substr
(
$value
,
3
,
1
)
!=
2
){
return
false
;
}
return
true
;
}
}
}
\ No newline at end of file
application/modules/Goods/controllers/Ota.php
View file @
e06effd8
...
@@ -69,6 +69,18 @@ class OtaController extends Base
...
@@ -69,6 +69,18 @@ class OtaController extends Base
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
}
/**
* 删除一个供应商
* @throws \App\Exception\custom\ParamException
*/
public
function
undeleteAction
()
{
(
new
OtaValidate
())
->
scene
(
'undelete'
)
->
validate
();
$res
=
OtaService
::
undeleteOne
(
$this
->
params
[
'ota_id'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
/**
* 更新供应商
* 更新供应商
...
...
application/services/goods/OtaService.php
View file @
e06effd8
...
@@ -5,6 +5,7 @@ namespace App\Services\goods;
...
@@ -5,6 +5,7 @@ namespace App\Services\goods;
use
App\Exception\custom\GoodsException
;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\Ota
;
use
Api\PhpServices\Printer\PrinterFactory
;
use
Api\PhpServices\Printer\PrinterFactory
;
use
Validate\OtaValidate
;
class
OtaService
class
OtaService
{
{
...
@@ -145,6 +146,16 @@ class OtaService
...
@@ -145,6 +146,16 @@ class OtaService
return
self
::
update
([
'ota_id'
=>
$otaId
,
'status'
=>
Ota
::
STATUS_DELETE
]);
return
self
::
update
([
'ota_id'
=>
$otaId
,
'status'
=>
Ota
::
STATUS_DELETE
]);
}
}
/**
* 取消删除供应商
* @param $otaId
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
unDeleteOne
(
$otaId
)
{
return
self
::
update
([
'ota_id'
=>
$otaId
,
'status'
=>
Ota
::
STATUS_NORMAL
]);
}
/**
/**
* 更新供应商信息
* 更新供应商信息
* @param $params
* @param $params
...
@@ -166,24 +177,53 @@ class OtaService
...
@@ -166,24 +177,53 @@ class OtaService
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
])
{
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
]
&&
$otaDetail
[
'printer_sn'
]
!=
$params
[
'printer_sn'
])
{
$printer
=
self
::
list
(
''
,
$params
[
'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
[
'printer_sn'
]);
if
(
$printer
[
'total'
]
>
0
)
{
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
);
);
}
}
try
{
$FeiPrinter
=
PrinterFactory
::
getPrinter
(
'Fei'
);
$FeiPrinter
->
addPrinter
([
'printer_sn'
=>
$params
[
'printer_sn'
],
'printer_key'
=>
$params
[
'printer_key'
],
'ota_name'
=>
$params
[
'ota_name'
],
]);
}
catch
(
\Exception
$e
)
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_BIND_ERROR
,
'data'
=>
[
$e
->
getMessage
()]]);
}
}
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
]
&&
$otaDetail
[
'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
)
{
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
LABEL_PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
[
'cus'
=>
GoodsException
::
LABEL_PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
);
);
}
}
try
{
$FeiPrinter
=
PrinterFactory
::
getPrinter
(
'Fei'
);
$FeiPrinter
->
addPrinter
([
'printer_sn'
=>
$params
[
'label_printer_sn'
],
'printer_key'
=>
$params
[
'label_printer_key'
],
'ota_name'
=>
$params
[
'ota_name'
],
]);
}
catch
(
\Exception
$e
)
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
PRINTER_BIND_ERROR
,
'data'
=>
[
$e
->
getMessage
()]]);
}
}
}
...
@@ -199,6 +239,15 @@ class OtaService
...
@@ -199,6 +239,15 @@ class OtaService
isset
(
$params
[
'address'
])
&&
$data
[
'address'
]
=
$params
[
'address'
];
isset
(
$params
[
'address'
])
&&
$data
[
'address'
]
=
$params
[
'address'
];
isset
(
$params
[
'status'
])
&&
$data
[
'status'
]
=
$params
[
'status'
];
isset
(
$params
[
'status'
])
&&
$data
[
'status'
]
=
$params
[
'status'
];
// 解绑
if
(
!
empty
(
$otaDetail
[
'printer_sn'
])
&&
empty
(
$params
[
'printer_sn'
])
&&
empty
(
$params
[
'printer_key'
]))
{
$data
[
'printer_sn'
]
=
$params
[
'printer_key'
]
=
''
;
}
if
(
!
empty
(
$otaDetail
[
'label_printer_sn'
])
&&
empty
(
$params
[
'label_printer_sn'
])
&&
empty
(
$params
[
'label_printer_key'
]))
{
$data
[
'label_printer_sn'
]
=
$params
[
'label_printer_key'
]
=
''
;
}
return
Ota
::
update
(
return
Ota
::
update
(
$data
,
$data
,
[
'ota_id'
=>
$params
[
'ota_id'
]]
[
'ota_id'
=>
$params
[
'ota_id'
]]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment