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
db64f257
Commit
db64f257
authored
Aug 02, 2021
by
suntengda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 供应商相关接口
parent
5f68b9f1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
122 additions
and
18 deletions
+122
-18
BaseException.php
application/exception/BaseException.php
+1
-1
GoodsException.php
application/exception/custom/GoodsException.php
+9
-0
Ota.php
application/modules/Goods/controllers/Ota.php
+1
-7
Takeplace.php
application/modules/Marketing/controllers/Takeplace.php
+74
-0
OtaService.php
application/services/goods/OtaService.php
+37
-10
No files found.
application/exception/BaseException.php
View file @
db64f257
...
@@ -40,7 +40,7 @@ class BaseException extends \Exception
...
@@ -40,7 +40,7 @@ class BaseException extends \Exception
$base_code
=
intval
(
$this
->
base_code
);
$base_code
=
intval
(
$this
->
base_code
);
$this
->
code
=
$codePrefix
+
$base_code
+
$cus_code
;
$this
->
code
=
$codePrefix
+
$base_code
+
$cus_code
;
$this
->
msg
=
$this
->
cus
[
$cus_code
];
$this
->
msg
=
isset
(
$params
[
'data'
])
?
vsprintf
(
$this
->
cus
[
$cus_code
],
$params
[
'data'
])
:
$this
->
cus
[
$cus_code
];
}
}
}
}
...
...
application/exception/custom/GoodsException.php
View file @
db64f257
...
@@ -10,6 +10,11 @@ class GoodsException extends BaseException
...
@@ -10,6 +10,11 @@ class GoodsException extends BaseException
{
{
protected
$base_code
=
Code
::
GOODS
;
protected
$base_code
=
Code
::
GOODS
;
const
OTA_ALREADY_EXIST
=
35
;
const
PRINTER_ALREADY_EXIST
=
36
;
const
EMPTY_OTA_ID
=
37
;
const
OTA_NOT_EXIST
=
38
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'商品创建失败,请稍后重试'
,
0
=>
'商品创建失败,请稍后重试'
,
1
=>
'店铺ID创建失败'
,
1
=>
'店铺ID创建失败'
,
...
@@ -46,5 +51,9 @@ class GoodsException extends BaseException
...
@@ -46,5 +51,9 @@ class GoodsException extends BaseException
32
=>
'当前商品已下单数量不足'
,
32
=>
'当前商品已下单数量不足'
,
33
=>
'售价不能为0'
,
33
=>
'售价不能为0'
,
34
=>
'售价不能大于5万元'
,
34
=>
'售价不能大于5万元'
,
self
::
OTA_ALREADY_EXIST
=>
'供应商已存在'
,
self
::
PRINTER_ALREADY_EXIST
=>
'打印机已被%s绑定'
,
self
::
EMPTY_OTA_ID
=>
'供应商id为空'
,
self
::
OTA_NOT_EXIST
=>
'供应商不存在'
,
];
];
}
}
\ No newline at end of file
application/modules/Goods/controllers/Ota.php
View file @
db64f257
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
use
App\Base\Base
;
use
App\Base\Base
;
use
App\Services\goods\OtaService
;
use
App\Services\goods\OtaService
;
use
\Validate\Ota\getBindListValidate
;
use
Validate\otaValidate
;
use
Validate\otaValidate
;
class
OtaController
extends
Base
class
OtaController
extends
Base
...
@@ -62,12 +61,7 @@ class OtaController extends Base
...
@@ -62,12 +61,7 @@ class OtaController extends Base
public
function
updateAction
()
public
function
updateAction
()
{
{
(
new
otaValidate
())
->
scene
(
'update'
)
->
validate
();
(
new
otaValidate
())
->
scene
(
'update'
)
->
validate
();
$data
=
[];
$res
=
OtaService
::
update
(
$this
->
params
);
$this
->
params
[
'ota_name'
]
&&
$data
[
'ota_name'
]
=
$this
->
params
[
'ota_name'
];
$this
->
params
[
'printer_sn'
]
&&
$data
[
'printer_sn'
]
=
$this
->
params
[
'printer_sn'
];
$this
->
params
[
'printer_key'
]
&&
$data
[
'printer_key'
]
=
$this
->
params
[
'printer_key'
];
$res
=
$data
?
OtaService
::
update
(
$this
->
params
[
'ota_id'
],
$data
)
:
true
;
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
}
...
...
application/modules/Marketing/controllers/Takeplace.php
0 → 100644
View file @
db64f257
<?php
/**
* Author : Tengda
* Date : 2021/7/29
* Time : 11:12 上午
*/
use
App\Base\Base
;
use
App\Services\marketing\TakePlaceService
;
use
Validate\TakePlaceValidate
;
class
TakeplaceController
extends
Base
{
/**
* 获取自提点列表
* http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71671761
* @throws \App\Exception\custom\ParamException
*/
public
function
listAction
()
{
(
new
TakePlaceValidate
())
->
scene
(
'list'
)
->
validate
();
$keywords
=
$this
->
params
[
'keywords'
]
??
''
;
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$res
=
TakePlaceService
::
searchList
(
$keywords
,
$offset
,
$limit
);
$this
->
success
([
'data'
=>
$res
]);
}
/**
* 添加自提点
* http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71671759
* @throws \App\Exception\custom\ParamException
*/
public
function
addAction
()
{
(
new
takePlaceValidate
())
->
scene
(
'add'
)
->
validate
();
$res
=
TakePlaceService
::
add
(
$this
->
params
);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
* 删除自提点
* @throws \App\Exception\custom\ParamException
*/
public
function
deleteAction
()
{
(
new
takePlaceValidate
())
->
scene
(
'delete'
)
->
validate
();
$res
=
TakePlaceService
::
delete
(
$this
->
params
[
'take_place_id'
]);
$this
->
success
([
'status'
=>
$res
?
'success'
:
'failed'
]);
}
/**
* 获取活动绑定的自提点列表
* @throws \App\Exception\custom\ParamException
*/
public
function
get_bind_listAction
()
{
(
new
takePlaceValidate
())
->
scene
(
'bindList'
)
->
validate
();
$marketingPindanId
=
$this
->
params
[
'marketing_pindan_id'
];
$offset
=
$this
->
params
[
'offset'
]
??
0
;
$limit
=
$this
->
params
[
'limit'
]
??
20
;
$data
=
TakePlaceService
::
getPindanTakePlaceList
(
$marketingPindanId
,
$offset
,
$limit
);
$this
->
success
([
'data'
=>
$data
]);
}
}
\ No newline at end of file
application/services/goods/OtaService.php
View file @
db64f257
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Services\goods
;
namespace
App\Services\goods
;
use
App\Exception\custom\GoodsException
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\Ota
;
class
OtaService
class
OtaService
...
@@ -40,16 +41,30 @@ class OtaService
...
@@ -40,16 +41,30 @@ class OtaService
*/
*/
public
static
function
detail
(
$OtaId
)
public
static
function
detail
(
$OtaId
)
{
{
return
Ota
::
get
(
self
::
COLUMNS
,[
'id'
=>
$OtaId
]);
return
Ota
::
get
(
self
::
COLUMNS
,[
'
ota_
id'
=>
$OtaId
]);
}
}
/**
* 添加供应商
* @param $params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws GoodsException
*/
public
static
function
add
(
$params
)
public
static
function
add
(
$params
)
{
{
//检查供应商是否已存在
if
(
self
::
list
(
$params
[
'ota_name'
])[
'total'
]
>
0
)
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
OTA_ALREADY_EXIST
]);
}
//@todo 检查商家是否已存在 -- 该商家已存在
//检查打印机是否已存在 -- 打印机已被(商家名称)绑定
$printer
=
self
::
list
(
''
,
$params
[
'printer_sn'
]);
//@todo 检查打印机是否已存在 -- 打印机已被(商家名称)绑定
if
(
$printer
[
'total'
]
>
0
)
{
throw
new
GoodsException
(
[
'cus'
=>
GoodsException
::
PRINTER_ALREADY_EXIST
,
'data'
=>
[
$printer
[
'list'
][
0
][
'ota_name'
]]]
);
}
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
];
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
];
...
@@ -59,7 +74,7 @@ class OtaService
...
@@ -59,7 +74,7 @@ class OtaService
}
}
/**
/**
* 删除
商家
* 删除
供应商
* @param $otaId
* @param $otaId
* @return \Api\PhpUtils\Mysql\MysqlBase
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
*/
...
@@ -72,16 +87,28 @@ class OtaService
...
@@ -72,16 +87,28 @@ class OtaService
}
}
/**
/**
*
@param $otaId
*
更新供应商信息
* @param $
data
* @param $
params
* @return \Api\PhpUtils\Mysql\MysqlBase
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws GoodsException
*/
*/
public
static
function
update
(
$
otaId
,
$data
)
public
static
function
update
(
$
params
)
{
{
//@todo 检查字段是否匹配
if
(
empty
(
$params
[
'ota_id'
]))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
EMPTY_OTA_ID
]);
}
//检查供应商是否存在
if
(
empty
(
self
::
detail
(
$params
[
'ota_id'
])))
{
throw
new
GoodsException
([
'cus'
=>
GoodsException
::
OTA_NOT_EXIST
]);
}
$data
=
[];
isset
(
$params
[
'ota_name'
])
&&
$data
[
'ota_name'
]
=
$params
[
'ota_name'
];
isset
(
$params
[
'printer_sn'
])
&&
$data
[
'printer_sn'
]
=
$params
[
'printer_sn'
];
isset
(
$params
[
'printer_key'
])
&&
$data
[
'printer_key'
]
=
$params
[
'printer_key'
];
return
Ota
::
update
(
return
Ota
::
update
(
$data
,
$data
,
[
'ota_id'
=>
$
otaId
]
[
'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