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
8e83f11f
Commit
8e83f11f
authored
Sep 10, 2021
by
mengweifu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:ota manage
parent
44a4419c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
6 deletions
+92
-6
GoodsException.php
application/exception/custom/GoodsException.php
+4
-0
OtaValidate.php
application/library/Validate/OtaValidate.php
+10
-2
Ota.php
application/modules/Goods/controllers/Ota.php
+3
-1
OtaService.php
application/services/goods/OtaService.php
+75
-3
No files found.
application/exception/custom/GoodsException.php
View file @
8e83f11f
...
...
@@ -16,6 +16,8 @@ class GoodsException extends BaseException
const
OTA_NOT_EXIST
=
38
;
const
RULE_LIMIT_ERROR
=
50
;
const
NOT_FIND_MARKETING
=
51
;
const
LABEL_PRINTER_ALREADY_EXIST
=
53
;
const
PRINTER_BIND_ERROR
=
54
;
protected
$cus
=
[
0
=>
'商品创建失败,请稍后重试'
,
...
...
@@ -71,5 +73,7 @@ class GoodsException extends BaseException
self
::
RULE_LIMIT_ERROR
=>
'单人可买上限填写错误'
,
self
::
NOT_FIND_MARKETING
=>
'找不到活动'
,
52
=>
'过期时间不得小于等于上架开始时间'
,
self
::
LABEL_PRINTER_ALREADY_EXIST
=>
'标签打印机已被%s绑定'
,
self
::
PRINTER_BIND_ERROR
=>
'打印机绑定失败:%s'
,
];
}
\ No newline at end of file
application/library/Validate/OtaValidate.php
View file @
8e83f11f
...
...
@@ -14,6 +14,10 @@ class OtaValidate extends \Validate\BaseValidate
protected
$rule
=
[
'ota_name'
=>
'require'
,
'ota_id'
=>
'require'
,
'address'
=>
'require'
,
'location'
=>
'require'
,
'longitude'
=>
'require'
,
'latitude'
=>
'require'
,
'offset'
=>
'egt:0'
,
'limit'
=>
'elt:100'
,
];
...
...
@@ -22,6 +26,10 @@ class OtaValidate extends \Validate\BaseValidate
protected
$message
=
[
"ota_name"
=>
"供应商名称不能为空"
,
"ota_id"
=>
"ota_id不能为空"
,
"address"
=>
"详细地址不能为空"
,
"location"
=>
"高德地图详细地址不能为空"
,
"longitude"
=>
"经度不能为空"
,
"latitude"
=>
"纬度不能为空"
,
"offset"
=>
"偏移量不能小于0"
,
"limit"
=>
"单次不能大于100条"
,
];
...
...
@@ -34,7 +42,7 @@ class OtaValidate extends \Validate\BaseValidate
public
function
sceneAdd
()
{
return
$this
->
only
([
'ota_name'
]);
return
$this
->
only
([
'ota_name'
,
'address'
,
'longitude'
,
'latitude'
,
'location'
]);
}
public
function
sceneDelete
()
{
...
...
@@ -43,7 +51,7 @@ class OtaValidate extends \Validate\BaseValidate
public
function
sceneUpdate
()
{
return
$this
->
only
([
'ota_id'
]);
return
$this
->
only
([
'ota_id'
,
'ota_name'
,
'address'
,
'longitude'
,
'latitude'
,
'location'
]);
}
public
function
sceneListByIds
()
{
...
...
application/modules/Goods/controllers/Ota.php
View file @
8e83f11f
...
...
@@ -22,9 +22,11 @@ class OtaController extends Base
$name
=
$this
->
params
[
'ota_name'
]
??
''
;
$printerSn
=
$this
->
params
[
'printer_sn'
]
??
''
;
$printerKey
=
$this
->
params
[
'printer_key'
]
??
''
;
$labelPrinterSn
=
$this
->
params
[
'label_printer_sn'
]
??
''
;
$labelPrinterKey
=
$this
->
params
[
'label_printer_key'
]
??
''
;
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$res
=
OtaService
::
list
(
$name
,
$printerSn
,
$printerKey
,
$offset
,
$limit
);
$res
=
OtaService
::
list
(
$name
,
$printerSn
,
$printerKey
,
$labelPrinterSn
,
$labelPrinterKey
,
$offset
,
$limit
);
$this
->
success
([
'result'
=>
$res
]);
}
...
...
application/services/goods/OtaService.php
View file @
8e83f11f
...
...
@@ -4,10 +4,11 @@ namespace App\Services\goods;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\Ota
;
use
Api\PhpServices\Printer\PrinterFactory
;
class
OtaService
{
const
COLUMNS
=
[
'ota_id'
,
'ota_name'
,
'printer_sn'
,
'printer_key'
,
'label_printer_sn'
,
'label_printer_key'
];
const
COLUMNS
=
[
'ota_id'
,
'ota_name'
,
'printer_sn'
,
'printer_key'
,
'label_printer_sn'
,
'label_printer_key'
,
'longitude'
,
'latitude'
,
'location'
,
'address'
];
/**
* 获取供应商列表(op 后台)
* @param string $otaName
...
...
@@ -17,11 +18,13 @@ class OtaService
* @param int $limit
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
static
function
list
(
$otaName
=
''
,
$printerSN
=
''
,
$printerKey
=
''
,
$offset
=
0
,
$limit
=
20
)
public
static
function
list
(
$otaName
=
''
,
$printerSN
=
''
,
$printerKey
=
''
,
$labelPrinterSN
=
''
,
$labelPrinterKey
=
''
,
$offset
=
0
,
$limit
=
20
)
{
$otaName
&&
$where
[
'ota_name'
]
=
$otaName
;
$printerSN
&&
$where
[
"printer_sn"
]
=
$printerSN
;
$printerKey
&&
$where
[
'printer_key'
]
=
$printerKey
;
$labelPrinterSN
&&
$where
[
"label_printer_sn"
]
=
$labelPrinterSN
;
$labelPrinterKey
&&
$where
[
'label_printer_key'
]
=
$labelPrinterKey
;
$where
[
'status'
]
=
Ota
::
STATUS_NORMAL
;
$where
[
'ORDER'
]
=
[
'ota_id'
=>
'DESC'
];
...
...
@@ -82,10 +85,52 @@ class OtaService
);
}
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
$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'
]]]
);
}
}
try
{
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
])
{
$FeiPrinter
=
PrinterFactory
::
getPrinter
(
'Fei'
);
$FeiPrinter
->
addPrinter
([
'printer_sn'
=>
$params
[
'printer_sn'
],
'printer_key'
=>
$params
[
'printer_key'
],
'ota_name'
=>
$params
[
'ota_name'
],
]);
}
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
$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
()]]
);
}
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
]
??
''
;
$data
[
'printer_key'
]
=
$params
[
'printer_key'
]
??
''
;
$data
[
'label_printer_sn'
]
=
$params
[
'label_printer_sn'
]
??
''
;
$data
[
'label_printer_key'
]
=
$params
[
'label_printer_key'
]
??
''
;
$data
[
'longitude'
]
=
$params
[
'longitude'
];
$data
[
'latitude'
]
=
$params
[
'latitude'
];
$data
[
'location'
]
=
$params
[
'location'
];
$data
[
'address'
]
=
$params
[
'address'
];
return
Ota
::
insert
(
$data
);
}
...
...
@@ -108,13 +153,40 @@ class OtaService
*/
public
static
function
update
(
$params
)
{
if
(
empty
(
$params
[
'ota_id'
]))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
EMPTY_OTA_ID
]);
}
$otaDetail
=
self
::
detail
(
$params
[
'ota_id'
]);
//检查供应商是否存在
if
(
empty
(
self
::
detail
(
$params
[
'ota_id'
])
))
{
if
(
empty
(
$otaDetail
))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
OTA_NOT_EXIST
]);
}
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
])
{
$printer
=
self
::
list
(
''
,
$params
[
'printer_sn'
]);
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
);
}
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
$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'
]]]
);
}
}
$data
=
[];
isset
(
$params
[
'ota_name'
])
&&
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
isset
(
$params
[
'printer_sn'
])
&&
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
];
...
...
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