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
85363ed9
Commit
85363ed9
authored
Sep 13, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/test' into test
# Conflicts: # application/services/user/UserService.php
parents
d10a3ead
f8a5231d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
6 deletions
+143
-6
GoodsException.php
application/exception/custom/GoodsException.php
+2
-0
OtaValidate.php
application/library/Validate/OtaValidate.php
+13
-0
Goods.php
application/modules/Goods/controllers/Goods.php
+10
-0
Ota.php
application/modules/Goods/controllers/Ota.php
+12
-0
GoodsSnapshotsService.php
application/services/goods/GoodsSnapshotsService.php
+40
-0
OtaService.php
application/services/goods/OtaService.php
+66
-6
No files found.
application/exception/custom/GoodsException.php
View file @
85363ed9
...
@@ -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 @
85363ed9
...
@@ -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/Goods.php
View file @
85363ed9
...
@@ -339,4 +339,14 @@ class GoodsController extends Base
...
@@ -339,4 +339,14 @@ class GoodsController extends Base
$res
=
GoodsService
::
getOtaInfoByGoodsSkuIds
(
$this
->
params
);
$res
=
GoodsService
::
getOtaInfoByGoodsSkuIds
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
$this
->
success
([
"result"
=>
$res
]);
}
}
/**
* 拼单商品快照批量获取
* @throws Exception
*/
public
function
goods_snapshotsAction
()
{
$res
=
GoodsSnapshotsService
::
goodsSnapshots
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
}
}
}
\ No newline at end of file
application/modules/Goods/controllers/Ota.php
View file @
85363ed9
...
@@ -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/GoodsSnapshotsService.php
View file @
85363ed9
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
App\Services\goods
;
namespace
App\Services\goods
;
use
Api\PhpUtils\Common\GoodsSkuId
;
use
App\Models\goods\mysql\GoodsSnapshot
;
use
App\Models\goods\mysql\PindanGoodsSnapshot
;
use
App\Models\goods\mysql\PindanGoodsSnapshot
;
class
GoodsSnapshotsService
class
GoodsSnapshotsService
...
@@ -32,4 +34,42 @@ class GoodsSnapshotsService
...
@@ -32,4 +34,42 @@ class GoodsSnapshotsService
}
}
return
$pindanGoodsSnapshot
;
return
$pindanGoodsSnapshot
;
}
}
/**
* 批量支持商品
* @param $params
* @return array
*/
public
static
function
goodsSnapshots
(
$params
)
{
$str
=
empty
(
$params
[
"snapshots_str"
])
?
""
:
$params
[
"snapshots_str"
];
$snapshot
=
[];
if
(
!
empty
(
$str
))
{
$paramsArr
=
json_decode
(
$str
,
true
);
if
(
!
empty
(
$paramsArr
))
{
foreach
(
$paramsArr
as
$param
)
{
if
(
isset
(
$param
[
"goods_sku_id"
])
||
isset
(
$param
[
"goods_version"
]))
{
$goodsSkuIdParams
=
GoodsSkuId
::
getGoodsSkuIdParams
(
$param
[
"goods_sku_id"
]);
$key
=
$param
[
"goods_sku_id"
]
.
"_"
.
$param
[
"goods_version"
];
if
(
$goodsSkuIdParams
[
"table_tag"
]
==
GoodsSkuId
::
TABLE_TAG_PINDAN
)
{
$snapshot
[
$key
]
=
PindanGoodsSnapshot
::
getRecord
([
"goods_sku_id"
=>
$param
[
"goods_sku_id"
],
"goods_version"
=>
$param
[
"goods_version"
]
]);
}
else
{
$snapshot
[
$key
]
=
GoodsSnapshot
::
getRecord
([
"goods_sku_id"
=>
$param
[
"goods_sku_id"
],
"goods_version"
=>
$param
[
"goods_version"
]
]);
}
if
(
!
empty
(
$snapshot
[
$key
][
"desc_pic_url"
]))
{
$ksyun
=
GoodsService
::
getUrlList
(
$snapshot
[
$key
][
"desc_pic_url"
]);
$snapshot
[
$key
][
"desc_pic_url_list"
]
=
$ksyun
;
}
}
}
}
}
return
$snapshot
;
}
}
}
\ No newline at end of file
application/services/goods/OtaService.php
View file @
85363ed9
...
@@ -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
{
{
...
@@ -77,8 +78,10 @@ class OtaService
...
@@ -77,8 +78,10 @@ class OtaService
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'printer_sn'
])
&&
$params
[
'printer_sn'
])
{
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'
]);
$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'
]]]
...
@@ -87,8 +90,11 @@ class OtaService
...
@@ -87,8 +90,11 @@ class OtaService
}
}
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
//检查标签打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
isset
(
$params
[
'label_printer_sn'
])
&&
$params
[
'label_printer_sn'
])
{
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
)
{
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'
]]]
...
@@ -145,6 +151,16 @@ class OtaService
...
@@ -145,6 +151,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 +182,53 @@ class OtaService
...
@@ -166,24 +182,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
[
'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
()]]);
}
}
}
...
@@ -191,8 +236,23 @@ class OtaService
...
@@ -191,8 +236,23 @@ class OtaService
isset
(
$params
[
'ota_name'
])
&&
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
isset
(
$params
[
'ota_name'
])
&&
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
isset
(
$params
[
'printer_sn'
])
&&
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
];
isset
(
$params
[
'printer_sn'
])
&&
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
];
isset
(
$params
[
'printer_key'
])
&&
$data
[
'printer_key'
]
=
$params
[
'printer_key'
];
isset
(
$params
[
'printer_key'
])
&&
$data
[
'printer_key'
]
=
$params
[
'printer_key'
];
isset
(
$params
[
'label_printer_sn'
])
&&
$data
[
'label_printer_sn'
]
=
$params
[
'label_printer_sn'
];
isset
(
$params
[
'label_printer_key'
])
&&
$data
[
'label_printer_key'
]
=
$params
[
'label_printer_key'
];
isset
(
$params
[
'longitude'
])
&&
$data
[
'longitude'
]
=
$params
[
'longitude'
];
isset
(
$params
[
'latitude'
])
&&
$data
[
'latitude'
]
=
$params
[
'latitude'
];
isset
(
$params
[
'location'
])
&&
$data
[
'location'
]
=
$params
[
'location'
];
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