Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
newShopBack
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
newshop
newShopBack
Commits
6ab6533a
Commit
6ab6533a
authored
Dec 04, 2019
by
姚书霞
🐘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
快递方式管理
parent
a126abcf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
288 additions
and
1 deletion
+288
-1
urlmanager.php
backend/config/urlmanager.php
+14
-0
CompanyController.php
backend/controllers/v1/transport/CompanyController.php
+182
-0
ShopBranch.php
backend/models/v1/branch/ShopBranch.php
+1
-1
ShopTransportCompany.php
backend/models/v1/transport/ShopTransportCompany.php
+91
-0
No files found.
backend/config/urlmanager.php
View file @
6ab6533a
...
@@ -153,6 +153,20 @@ return [
...
@@ -153,6 +153,20 @@ return [
'DELETE,OPTIONS city-distribution-setting-delete'
=>
'city-distribution-setting-delete'
,
'DELETE,OPTIONS city-distribution-setting-delete'
=>
'city-distribution-setting-delete'
,
],
],
],
],
//快递方式
[
'class'
=>
'yii\rest\UrlRule'
,
'controller'
=>
[
'v1/transport/company'
,
],
'extraPatterns'
=>
[
'GET,OPTIONS company-list'
=>
'company-list'
,
'GET,OPTIONS company-detail'
=>
'company-detail'
,
'POST,OPTIONS company-add'
=>
'company-add'
,
'PUT,OPTIONS company-revise'
=>
'company-revise'
,
'DELETE,OPTIONS company-delete'
=>
'company-delete'
,
],
],
//用户列表
//用户列表
[
[
'class'
=>
'yii\rest\UrlRule'
,
'class'
=>
'yii\rest\UrlRule'
,
...
...
backend/controllers/v1/transport/CompanyController.php
0 → 100644
View file @
6ab6533a
<?php
namespace
backend\controllers\v1\transport
;
use
Yii
;
use
backend\controllers\v1\BaseController
;
use
backend\helpers\Func
;
use
yii\data\ActiveDataProvider
;
use
yii\web\BadRequestHttpException
;
use
yii\web\ServerErrorHttpException
;
class
CompanyController
extends
BaseController
{
public
$modelClass
=
'app\models\v1\transport\ShopTransportCompany'
;
/**
* @OA\Get(
* path="/backend/web/v1/transport/companies/company-list",
* tags={"配送管理"},
* summary="快递方式列表(姚书侠)",
* description="快递方式列表接口",
* @OA\Parameter(in = "query",name = "page",description = "分页页码",required = false,@OA\Schema(type="string")),
* @OA\Parameter(in = "query",name = "pageSize",description = "分页大小",required = false,@OA\Schema(type="string")),
* @OA\Response(response = 200,description = "success"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionCompanyList
()
{
$params
=
Yii
::
$app
->
request
->
getQueryparams
();
$query
=
$this
->
modelClass
::
find
();
return
new
ActiveDataProvider
(
[
'query'
=>
$query
,
'pagination'
=>
[
'pageSize'
=>
$params
[
'pageSize'
]
??
20
,
]
]
);
}
/**
* @OA\Get(
* path="/backend/web/v1/transport/companies/company-detail",
* tags={"配送管理"},
* summary="快递方式详情接口(姚书侠)",
* description="快递方式详情接口",
* @OA\Parameter(name="guid",in="query",required=true,description="快递方式id",@OA\Schema(type="string")),
* @OA\Response(response = 200,description = "success"),
* security={{"Authorization": {}}}
* )
*/
//编辑用
public
function
actionCompanyDetail
()
{
$guid
=
Yii
::
$app
->
request
->
getQueryparam
(
'guid'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
return
$model
;
}
/**
* @OA\POST(
* path="/backend/web/v1/transport/companies/company-add",
* tags={"配送管理"},
* summary="添加快递方式接口(姚书侠)",
* description="添加快递方式接口",
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="NAME",description="快递方式名称,最长20字",type="string"),
* @OA\Property(property="IS_DEFAULT",description="是否默认发货快递 0否1是",type="string"),
* @OA\Property(property="CODE",description="快递编号",type="string"),
* @OA\Property(property="PHONE",description="电话",type="string"),
* @OA\Property(property="DESCRIPTION",description="描述",type="string"),
* )
* )
* ),
* @OA\Response(response=201,description="success"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionCompanyAdd
()
{
$model
=
new
$this
->
modelClass
();
$model
->
scenario
=
'create'
;
//创建的场景
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
'100'
,
//Yii::$app->user->identity->ORG_GUID,
);
$model
->
setAttributes
(
$other_param
);
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
if
(
$model
->
save
())
{
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
201
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to create the object for unknown reason.'
);
}
return
$model
;
}
/**
* @OA\PUT(
* path="/backend/web/v1/transport/companies/company-revise",
* tags={"配送管理"},
* summary="修改快递方式接口(姚书侠)",
* description="修改快递方式接口",
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="GUID",description="要修改的快递方式GUID",type="string"),
* @OA\Property(property="NAME",description="快递方式名称,最长20字",type="string"),
* @OA\Property(property="IS_DEFAULT",description="是否默认发货快递 0否1是",type="string"),
* @OA\Property(property="CODE",description="快递编号",type="string"),
* @OA\Property(property="PHONE",description="电话",type="string"),
* @OA\Property(property="DESCRIPTION",description="描述",type="int"),
* )
* )
* ),
* @OA\Response(response=200,description="成功时返回access-token"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionCompanyRevise
()
{
$guid
=
Yii
::
$app
->
request
->
getBodyparam
(
'GUID'
);
// var_dump($guid);die;
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录'
);
}
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.'
);
}
return
$model
;
}
/**
* @OA\DELETE(
* path="/backend/web/v1/transport/companies/company-delete",
* tags={"配送管理"},
* summary="删除快递方式接口(姚书侠)",
* description="删除快递方式接口",
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="GUID",description="要删除的快递方式GUID",type="string"),
* )
* )
* ),
* @OA\Response(response=200,description="成功时返回access-token"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionCompanyDelete
()
{
$guid
=
Yii
::
$app
->
request
->
getBodyparam
(
'GUID'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录'
);
}
else
if
(
$model
->
delete
()
===
false
)
{
throw
new
ServerErrorHttpException
(
'Failed to delete the object for unknown reason.'
);
}
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
return
$model
;
}
}
\ No newline at end of file
backend/models/v1/branch/ShopBranch.php
View file @
6ab6533a
...
@@ -347,7 +347,7 @@ class ShopBranch extends BaseModel
...
@@ -347,7 +347,7 @@ class ShopBranch extends BaseModel
return
$query
;
return
$query
;
}
}
/**
/**
* 查询
门店
列表
* 查询
DC
列表
* @params array $params 查询参数数组
* @params array $params 查询参数数组
* @return array|null 返回查询结果
* @return array|null 返回查询结果
*/
*/
...
...
backend/models/v1/transport/ShopTransportCompany.php
0 → 100644
View file @
6ab6533a
<?php
namespace
app\models\v1\transport
;
use
Yii
;
use
app\models\v1\BaseModel
;
/**
* This is the model class for table "shop_transport_company".
*
* @property string $GUID 快递方式GUID
* @property string $ORG_GUID 组织机构号
* @property string $CODE 快递方式CODE
* @property string $NAME 快递方式名字
* @property string $PHONE 快递方式电话
* @property int $SORT 排序
* @property string $DESCRIPTION 快递方式描述
* @property int $IS_DEFAULT 是否默认快递方式 1是 0 否
* @property string $NAME_SPELL 快递方式名字拼写
* @property string $KUAIDI100_CODE 快递100编号
*/
class
ShopTransportCompany
extends
BaseModel
{
const
SCENARIO_CREATE
=
'create'
;
const
SCENARIO_UPDATE
=
'update'
;
/**
* {@inheritdoc}
*/
public
static
function
tableName
()
{
return
'shop_transport_company'
;
}
/**
* 场景值的重写
* {@inheritdoc}
*/
public
function
scenarios
()
{
return
[
self
::
SCENARIO_CREATE
=>
[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'NAME'
,
'PHONE'
,
'DESCRIPTION'
,
'IS_DEFAULT'
],
self
::
SCENARIO_UPDATE
=>
[
'CODE'
,
'NAME'
,
'PHONE'
,
'DESCRIPTION'
,
'IS_DEFAULT'
],
];
}
/**
* {@inheritdoc}
*/
public
function
rules
()
{
return
[
[[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'message'
=>
'{attribute}为必填项'
,
'on'
=>
[
'create'
]],
[[
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'message'
=>
'{attribute}为必填项'
,
'on'
=>
[
'update'
]],
[[
'PHONE'
],
'match'
,
'pattern'
=>
'/^1\d{10}$/'
,
'message'
=>
'手机号格式不正确'
],
[[
'IS_DEFAULT'
],
'boolean'
,
'message'
=>
'{attribute}传值错误'
],
];
}
/**
* {@inheritdoc}
*/
public
function
attributeLabels
()
{
return
[
'GUID'
=>
'Guid'
,
'ORG_GUID'
=>
'Org Guid'
,
'CODE'
=>
'快递编号'
,
'NAME'
=>
'快递名称'
,
'PHONE'
=>
'手机号'
,
'SORT'
=>
'排序'
,
'DESCRIPTION'
=>
'描述'
,
'IS_DEFAULT'
=>
'是否默认发货快递'
,
'NAME_SPELL'
=>
'Name Spell'
,
'KUAIDI100_CODE'
=>
'Kuaidi100 Code'
,
];
}
/**
* 重写fields 显示字段过滤
*/
public
function
fields
()
{
$fields
=
parent
::
fields
();
// return [
// 'GUID',
// ];
unset
(
$fields
[
'ORG_GUID'
],
$fields
[
'NAME_SPELL'
],
$fields
[
'KUAIDI100_CODE'
]);
return
$fields
;
}
}
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