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
c526b25e
Commit
c526b25e
authored
Dec 04, 2019
by
张晓林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配送方式添加。修改
parent
243122e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
214 additions
and
0 deletions
+214
-0
urlmanager.php
backend/config/urlmanager.php
+3
-0
TransportMethodController.php
...nd/controllers/v1/transport/TransportMethodController.php
+181
-0
TransportMethod.php
backend/models/v1/transport/TransportMethod.php
+30
-0
No files found.
backend/config/urlmanager.php
View file @
c526b25e
...
@@ -260,6 +260,9 @@ return [
...
@@ -260,6 +260,9 @@ return [
],
],
'extraPatterns'
=>
[
'extraPatterns'
=>
[
'GET,OPTIONS get-transport-method'
=>
'get-transport-method'
,
'GET,OPTIONS get-transport-method'
=>
'get-transport-method'
,
'GET,OPTIONS make-use'
=>
'make-use'
,
'POST,OPTIONS transport-method-insert'
=>
'transport-method-insert'
,
'PUT,OPTIONS transport-method-update'
=>
'transport-method-update'
,
],
],
],
],
],
],
...
...
backend/controllers/v1/transport/TransportMethodController.php
0 → 100644
View file @
c526b25e
<?php
namespace
backend\controllers\v1\transport
;
use
Yii
;
use
backend\controllers\v1\BaseController
;
use
backend\models\v1\transport\TransportMethod
;
use
yii\data\ActiveDataProvider
;
use
backend\helpers\Func
;
class
TransportMethodController
extends
BaseController
{
public
$modelClass
=
'backend\models\v1\transport\TransportMethod'
;
/**
* @OA\GET(
* path="/backend/web/v1/transport/transport-methods/get-transport-method",
* tags={"配送管理"},
* summary="配送方式列表(张晓林)",
* description="配送方式列表",
* @OA\Parameter(name="page",in="query",description="分页页码",@OA\Schema(type="int")),
* @OA\Response(response="200",description="
* GUID:配送方式GUID,
* CODE:配送方式CODE
* NAME:名称,
* DESCRIPTION:描述,
* STATE:是否启用:1 启用 0 不启用,
* IS_UNDERLINE_PAY:是否支持线下付款 1 支持 0 不支持,
* POINTS_STATE:在积分商城中是否启用:1 启用 0 不启用,
* ROMENS_RENT_STATE:在小程序中是否启用:1 启用 0 不启用,
* DSDINTERVAL:定时达时间间隔,
* TRANSPOR_TYPE:配送方式类型:1 门店B2C配送 2 门店O2O配送方式 3 DC仓B2C,
* EXTRA_MONEY:额外费用,
* DELIVERY_TIME:配送时间,
* ORDER_INDEX:排序序号"),
* security={{"Authorization":{}}}
* )
*/
public
function
actionGetTransportMethod
(){
$model
=
new
TransportMethod
();
$columnArr
=
array
(
'GUID'
,
'CODE'
,
'NAME'
,
'DESCRIPTION'
,
'STATE'
,
'IS_UNDERLINE_PAY'
,
'POINTS_STATE'
,
'ROMENS_RENT_STATE'
,
'DSDINTERVAL'
,
'TRANSPOR_TYPE'
,
'EXTRA_MONEY'
,
'DELIVERY_TIME'
,
'ORDER_INDEX'
);
$query
=
$model
::
find
()
->
select
(
$columnArr
)
->
where
([
'ORG_GUIF'
=>
\Yii
::
$app
->
user
->
identity
->
ORG_GUID
])
->
orderBy
(
'ORDER_INDEX DESC'
);
// $query = $model::find()->select($columnArr)->orderBy('ORDER_INDEX DESC');
return
new
ActiveDataProvider
([
'query'
=>
$query
,
'pagination'
=>
[
'pageSize'
=>
15
,
]
]);
}
/**
* @OA\GET(
* path="/backend/web/v1/transport/transport-methods/make-use",
* tags={"配送管理"},
* summary="配送方式列表(张晓林)",
* description="配送方式列表",
* @OA\Parameter(name="GUID",in="query",description="配送方式GUID",@OA\Schema(type="int")),
* @OA\Parameter(name="TYPE",in="query",description="是积分商城还是小程序 1 积分商城 2 小程序",@OA\Schema(type="int")),
* @OA\Parameter(name="NUMBER",in="query",description="是启用还是关闭 1 启用 0 关闭",@OA\Schema(type="int")),
* @OA\Response(response="200",description=""),
* security={{"Authorization":{}}}
* )
*/
public
function
actionMakeUse
(){
$param
=
Yii
::
$app
->
request
->
get
();
$model
=
new
TransportMethod
();
$model
->
scenario
=
'makeUse'
;
$model
->
attributes
=
$param
;
if
(
$model
->
validate
()){
$transportInfo
=
$model
::
findOne
([
'GUID'
=>
$param
[
'GUID'
]]);
$transportInfo
->
TYPE
=
$param
[
'TYPE'
];
$transportInfo
->
NUMBER
=
$param
[
'NUMBER'
];
if
(
$param
[
'TYPE'
]
==
1
){
$transportInfo
->
POINTS_STATE
=
$param
[
'NUMBER'
];
}
elseif
(
$param
[
'TYPE'
]
==
2
){
$transportInfo
->
ROMENS_RENT_STATE
=
$param
[
'NUMBER'
];
}
if
(
$transportInfo
->
save
()){
return
[
'CODE'
=>
200
,
'MESSAGE'
=>
'更新成功'
];
}
else
{
return
$model
->
errors
;
}
}
else
{
return
$model
->
errors
;
}
}
/**
* @OA\POST(
* path="/backend/web/v1/transport/transport-methods/transport-method-insert",
* tags={"配送管理"},
* summary="添加配送方式(张晓林)",
* description="添加配送方式",
* * @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="application/x-www-form-urlencoded",
* @OA\Schema(
* type="object",
* @OA\Property(property="NAME",description="名称",type="string"),
* @OA\Property(property="DSDINTERVAL",description="小时数",type="string"),
* @OA\Property(property="EXTRA_MONEY",description="额外配送费用",type="string"),
* @OA\Property(property="TRANSPOR_TYPE",description="配送类型 1 门店B2C配送 2 门店O2O配送方式 3 DC仓B2C",type="string"),
* @OA\Property(property="ORDER_INDEX",description="排序",type="string"),
* @OA\Property(property="IS_UNDERLINE_PAY",description="是否支持线下付款 1 是 0 否",type="string"),
* @OA\Property(property="DESCRIPTION",description="描述",type="string"),
* )
* )
* ),
* @OA\Response(response=200,description="success"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionTransportMethodInsert
(){
$param
=
Yii
::
$app
->
request
->
post
();
$model
=
new
TransportMethod
();
$model
->
scenario
=
'insert'
;
$model
->
GUID
=
Func
::
create_guid
();
// $model->ORG_GUID=\Yii::$app->user->identity->ORG_GUID;
$model
->
ORG_GUID
=
'100'
;
$model
->
attributes
=
$param
;
if
(
$model
->
save
()){
return
[
'CODE'
=>
200
,
'MESSAGE'
=>
'添加成功'
];
}
else
{
return
$model
->
errors
;
}
}
/**
* @OA\PUT(
* path="/backend/web/v1/transport/transport-methods/transport-method-update",
* 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="名称",type="string"),
* @OA\Property(property="DSDINTERVAL",description="小时数",type="string"),
* @OA\Property(property="EXTRA_MONEY",description="额外配送费用",type="string"),
* @OA\Property(property="TRANSPOR_TYPE",description="配送类型 1 门店B2C配送 2 门店O2O配送方式 3 DC仓B2C",type="string"),
* @OA\Property(property="ORDER_INDEX",description="排序",type="string"),
* @OA\Property(property="IS_UNDERLINE_PAY",description="是否支持线下付款 1 是 0 否",type="string"),
* @OA\Property(property="DESCRIPTION",description="描述",type="string"),
* )
* )
* ),
* @OA\Response(response=200,description="success"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionTransportMethodUpdate
(){
$param
=
Yii
::
$app
->
request
->
post
();
$model
=
new
TransportMethod
();
$model
=
$model
::
findOne
([
'GUID'
=>
$param
[
'GUID'
]]);
$model
->
scenario
=
'update'
;
$model
->
attributes
=
$param
;
if
(
$model
->
save
()){
return
[
'CODE'
=>
200
,
'MESSAGE'
=>
'更新成功'
];
}
else
{
return
$model
->
errors
;
}
}
}
backend/models/v1/transport/TransportMethod.php
0 → 100644
View file @
c526b25e
<?php
namespace
backend\models\v1\transport
;
use
yii\data\ActiveDataProvider
;
use
app\models\v1\BaseModel
;
class
TransportMethod
extends
BaseModel
{
public
$TYPE
;
public
$NUMBER
;
public
static
function
tableName
(){
return
'shop_transport_type'
;
}
public
function
rules
()
{
return
[
[
'GUID'
,
'required'
,
'on'
=>
[
'makeUse'
,
'insert'
,
'update'
],
'message'
=>
'缺少GUID'
],
[
'GUID'
,
'unique'
,
'on'
=>
'insert'
,
'message'
=>
'GUID不能有重复值'
],
[[
'TYPE'
,
'NUMBER'
],
'integer'
,
'on'
=>
'makeUse'
,
'message'
=>
'必须为整数'
],
[
'NAME'
,
'required'
,
'on'
=>
[
'insert'
,
'update'
],
'message'
=>
'名称不能为空'
],
[
'NAME'
,
'string'
,
'min'
=>
1
,
'max'
=>
20
,
'on'
=>
[
'insert'
,
'update'
],
'message'
=>
'最多20个字'
],
[
'DESCRIPTION'
,
'string'
,
'min'
=>
1
,
'max'
=>
50
,
'on'
=>
[
'insert'
,
'update'
],
'message'
=>
'最多50个字'
],
[[
'DSDINTERVAL'
,
'EXTRA_MONEY'
,
'ORDER_INDEX'
,
'DELIVERY_TIME'
],
'default'
,
'value'
=>
0
,
'on'
=>
[
'insert'
,
'update'
]],
[[
'DSDINTERVAL'
,
'EXTRA_MONEY'
,
'ORDER_INDEX'
],
'number'
,
'on'
=>
[
'insert'
,
'update'
],
'message'
=>
'必须为数字'
],
[
'STATE'
,
'default'
,
'value'
=>
1
,
'on'
=>
'insert'
],
[[
'POINTS_STATE'
,
'ROMENS_RENT_STATE'
],
'default'
,
'value'
=>
1
,
'on'
=>
'insert'
],
[[
'IS_UNDERLINE_PAY'
,
'TRANSPOR_TYPE'
],
'integer'
,
'on'
=>
[
'insert'
,
'update'
]],
];
}
}
\ No newline at end of file
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