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
9dd55ea4
Commit
9dd55ea4
authored
Jan 02, 2020
by
孙磊
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of
http://gitlab-ebiz.yiyao365.cn/newshop/newshopback
into development
parents
34a45774
097b0e1b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
64 deletions
+102
-64
BaseController.php
backend/controllers/v1/BaseController.php
+2
-1
ShopUserMembergradeController.php
...controllers/v1/shopuser/ShopUserMembergradeController.php
+70
-35
CompanyController.php
backend/controllers/v1/transport/CompanyController.php
+5
-5
ShopUserMembergrade.php
backend/models/v1/shopuser/ShopUserMembergrade.php
+24
-22
ShopTransportCompany.php
backend/models/v1/transport/ShopTransportCompany.php
+1
-1
No files found.
backend/controllers/v1/BaseController.php
View file @
9dd55ea4
...
...
@@ -22,7 +22,7 @@ use backend\components\v1\authorizationFilter;
* ),
* @OA\Server(
* description="Api server",
* url="/
guoyongzhi/weiShopNew
",
* url="/
yaoshuxia/shopback
",
* ),
* @OA\SecurityScheme(
* securityScheme="Authorization",
...
...
@@ -60,6 +60,7 @@ class BaseController extends ActiveController
public
$serializer
=
[
'class'
=>
'yii\rest\Serializer'
,
'collectionEnvelope'
=>
'data'
,
'preserveKeys'
=>
true
,
];
public
function
behaviors
()
{
...
...
backend/controllers/v1/shopuser/ShopUserMembergradeController.php
View file @
9dd55ea4
...
...
@@ -6,8 +6,7 @@ use Yii;
use
backend\controllers\v1\BaseController
;
use
backend\helpers\Func
;
use
yii\data\ActiveDataProvider
;
use
yii\web\BadRequestHttpException
;
use
yii\web\ServerErrorHttpException
;
use
yii\web\HttpException
;
class
ShopUserMembergradeController
extends
BaseController
{
...
...
@@ -33,14 +32,24 @@ class ShopUserMembergradeController extends BaseController
* 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"),
* @OA\Response(response = 200,description = "
* GUID:用户组GUID,
* NAME:用户组名称,
* IS_DEFAULT:是否默认用户组,
* CREATE_TIME:创建时间,
* GRADE_PERCENT:优惠百分比,
* MONEY_POINT_SRATE:购物获得积分比率
* IS_SETRANGE:优惠范围 0:全店通用 1:指定商品 2.指定促销分类
* "),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
//重写index
public
function
actionMembergradeList
()
{
$requestParams
=
Yii
::
$app
->
getRequest
()
->
get
();
$requestParams
=
Yii
::
$app
->
request
->
getQueryparams
();
$query
=
$this
->
modelClass
::
find
();
return
new
ActiveDataProvider
(
...
...
@@ -60,16 +69,33 @@ class ShopUserMembergradeController extends BaseController
* summary="用户组详情接口(姚书侠)",
* description="用户组详情接口",
* @OA\Parameter(name="guid",in="query",required=true,description="用户组id",@OA\Schema(type="string")),
* @OA\Response(response = 200,description = "success"),
* @OA\Response(response = 200,description = "
* GUID:用户组GUID,
* NAME:用户组名称,
* IS_DEFAULT:是否默认用户组,
* CREATE_TIME:创建时间,
* GRADE_PERCENT:优惠百分比,
* MONEY_POINT_SRATE:购物获得积分比率
* IS_SETRANGE:优惠范围 0:全店通用 1:指定商品 2.指定促销分类
* "),
* @OA\Response(response = 400,description = "失败的请求"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
//编辑用
public
function
actionMembergradeDetail
()
{
$guid
=
Yii
::
$app
->
getRequest
()
->
get
(
'guid'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
return
$model
;
$guid
=
Yii
::
$app
->
request
->
getQueryparam
(
'guid'
);
$result
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$result
)
throw
new
HttpException
(
400
,
'记录不存在'
);
return
new
ActiveDataProvider
(
[
'models'
=>
$result
->
toArray
(),
'pagination'
=>
false
]
);
}
/**
...
...
@@ -87,32 +113,36 @@ class ShopUserMembergradeController extends BaseController
* @OA\Property(property="NAME",description="用户组名称,最长20字",type="string"),
* @OA\Property(property="IS_DEFAULT",description="是否默认用户组 0否1是",type="string"),
* @OA\Property(property="GRADE_PERCENT",description="优惠百分比 浮点型",type="string"),
* @OA\Property(property="IS_SETRANGE",description="
0
:全店通用 1:指定商品 2.指定促销分类",type="string"),
* @OA\Property(property="IS_SETRANGE",description="
优惠范围
:全店通用 1:指定商品 2.指定促销分类",type="string"),
* @OA\Property(property="MONEY_POINT_SRATE",description="购物获得积分比率 浮点型",type="string"),
* )
* )
* ),
* @OA\Response(response=200,description="success"),
* @OA\Response(response = 201,description = "添加成功"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 422,description = "数据验证未通过"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionMembergradeAdd
()
{
$model
=
new
$this
->
modelClass
();
$model
->
scenario
=
'create'
;
//创建的场景
$other_param
=
array
(
'GUID'
=>
Func
::
create_guid
(),
'ORG_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
,
'ORG_GUID'
=>
Yii
::
$app
->
user
->
identity
->
ORG_GUID
,
//Yii::$app->user->identity->ORG_GUID,
);
$model
->
setAttributes
(
$other_param
,
false
);
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
$model
->
setAttributes
(
$other_param
);
if
(
$model
->
save
())
{
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
201
);
throw
new
HttpException
(
201
,
'添加成功'
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to create the object for unknown reason.'
);
throw
new
HttpException
(
500
,
'添加失败'
);
}
else
{
return
$model
;
}
return
$model
;
}
/**
...
...
@@ -136,25 +166,29 @@ class ShopUserMembergradeController extends BaseController
* )
* )
* ),
* @OA\Response(response=200,description="成功时返回access-token"),
* security={{"Authorization": {}}}
* @OA\Response(response = 200,description = "修改成功"),
* @OA\Response(response = 400,description = "失败的请求"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 422,description = "数据验证未通过"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionMembergradeRevise
()
{
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'GUID'
);
$guid
=
Yii
::
$app
->
request
->
getBodyparam
(
'GUID'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录'
);
}
if
(
!
$model
)
throw
new
HttpException
(
400
,
'记录不存在'
);
$model
->
scenario
=
'update'
;
//创建的场景
$model
->
setAttributes
(
Yii
::
$app
->
getRequest
()
->
post
());
$model
->
setAttributes
(
Yii
::
$app
->
request
->
getBodyparams
());
if
(
$model
->
save
()
===
false
&&
!
$model
->
hasErrors
())
{
throw
new
ServerErrorHttpException
(
'Failed to update the object for unknown reason.'
);
if
(
$model
->
save
())
{
throw
new
HttpException
(
200
,
'修改成功'
);
}
elseif
(
!
$model
->
hasErrors
())
{
throw
new
HttpException
(
500
,
'添加失败'
);
}
else
{
return
$model
;
}
return
$model
;
}
/**
...
...
@@ -173,22 +207,23 @@ class ShopUserMembergradeController extends BaseController
* )
* )
* ),
* @OA\Response(response=200,description="成功时返回access-token"),
* @OA\Response(response = 204,description = "删除成功"),
* @OA\Response(response = 400,description = "失败的请求"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
* )
*/
public
function
actionMembergradeDelete
()
{
$guid
=
Yii
::
$app
->
getRequest
()
->
post
(
'GUID'
);
$guid
=
Yii
::
$app
->
request
->
getBodyparam
(
'GUID'
);
$model
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$model
){
throw
new
BadRequestHttpException
(
'没有找到记录
'
);
throw
new
HttpException
(
400
,
'记录不存在
'
);
}
else
if
(
$model
->
delete
()
===
false
)
{
throw
new
ServerErrorHttpException
(
'Failed to delete the object for unknown reason.
'
);
throw
new
HttpException
(
500
,
'删除失败
'
);
}
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
return
$model
;
throw
new
HttpException
(
204
,
'删除成功'
);
}
}
\ No newline at end of file
backend/controllers/v1/transport/CompanyController.php
View file @
9dd55ea4
...
...
@@ -65,6 +65,7 @@ class CompanyController extends BaseController
* DESCRIPTION:描述,
* IS_DEFAULT:是否默认 1是0否
* "),
* @OA\Response(response = 400,description = "失败的请求"),
* @OA\Response(response = 403,description = "权限错误"),
* @OA\Response(response = 500,description = "系统错误"),
* security={{"Authorization": {}}}
...
...
@@ -74,10 +75,11 @@ class CompanyController extends BaseController
public
function
actionCompanyDetail
()
{
$guid
=
Yii
::
$app
->
request
->
getQueryparam
(
'guid'
);
$result
=
$this
->
modelClass
::
findOne
(
$guid
)
->
toArray
();
$result
=
$this
->
modelClass
::
findOne
(
$guid
);
if
(
!
$result
)
throw
new
HttpException
(
400
,
'记录不存在'
);
return
new
ActiveDataProvider
(
[
'models'
=>
$result
,
'models'
=>
$result
->
toArray
()
,
'pagination'
=>
false
]
);
...
...
@@ -210,9 +212,7 @@ class CompanyController extends BaseController
}
else
if
(
$model
->
delete
()
===
false
)
{
throw
new
HttpException
(
500
,
'删除失败'
);
}
Yii
::
$app
->
getResponse
()
->
setStatusCode
(
204
);
return
null
;
throw
new
HttpException
(
204
,
'删除成功'
);
}
}
\ No newline at end of file
backend/models/v1/shopuser/ShopUserMembergrade.php
View file @
9dd55ea4
...
...
@@ -21,8 +21,8 @@ use yii\db\Expression;
*/
class
ShopUserMembergrade
extends
BaseModel
{
//
const SCENARIO_CREATE = 'create';
//
const SCENARIO_UPDATE = 'update';
const
SCENARIO_CREATE
=
'create'
;
const
SCENARIO_UPDATE
=
'update'
;
/**
* {@inheritdoc}
...
...
@@ -55,13 +55,14 @@ class ShopUserMembergrade extends BaseModel
* 场景值的重写
* {@inheritdoc}
*/
// public function scenarios()
// {
// return [
// self::SCENARIO_CREATE => ['a', 'aw'],
// self::SCENARIO_UPDATE => ['username', 'email', 'password'],
// ];
// }
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIO_CREATE
=>
[
'GUID'
,
'ORG_GUID'
,
'NAME'
,
'IS_DEFAULT'
,
'CREATE_TIME'
,
'GRADE_PERCENT'
,
'MONEY_POINT_SRATE'
,
'IS_SETRANGE'
],
self
::
SCENARIO_UPDATE
=>
[
'NAME'
,
'IS_DEFAULT'
,
'GRADE_PERCENT'
,
'MONEY_POINT_SRATE'
,
'IS_SETRANGE'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
/**
* 验证
...
...
@@ -71,7 +72,8 @@ class ShopUserMembergrade extends BaseModel
{
return
[
[[
'NAME'
,
'GRADE_PERCENT'
,
'MONEY_POINT_SRATE'
],
'trim'
],
[[
'NAME'
,
'GRADE_PERCENT'
,
'MONEY_POINT_SRATE'
],
'required'
],
[[
'GUID'
,
'ORG_GUID'
,
'NAME'
,
'GRADE_PERCENT'
,
'MONEY_POINT_SRATE'
,
'IS_SETRANGE'
],
'required'
,
'on'
=>
[
self
::
SCENARIO_CREATE
]],
[[
'NAME'
,
'GRADE_PERCENT'
,
'MONEY_POINT_SRATE'
,
'IS_SETRANGE'
],
'required'
,
'on'
=>
[
self
::
SCENARIO_UPDATE
]],
[[
'GRADE_PERCENT'
,
'MONEY_POINT_SRATE'
],
'double'
],
[[
'IS_DEFAULT'
],
'boolean'
],
[[
'IS_SETRANGE'
],
'in'
,
'range'
=>
[
0
,
1
,
2
]],
...
...
@@ -85,17 +87,17 @@ class ShopUserMembergrade extends BaseModel
*/
public
function
attributeLabels
()
{
//
return [
//
'GUID' => 'Guid',
// 'ORG_GUID' => 'Org Guid
',
// 'NAME' => 'Name
',
// 'IS_DEFAULT' => 'Is Default
',
// 'CREATE_TIME' => 'Create Time
',
// 'GRADE_PERCENT' => 'Grade Percent
',
// 'USER_POINTS' => 'User Points
',
// 'MONEY_POINT_SRATE' => 'Money Point Srate
',
// 'IS_SETRANGE' => 'Is Setrange
',
//
];
return
[
'GUID'
=>
'Guid'
,
'ORG_GUID'
=>
'组织机构号
'
,
'NAME'
=>
'用户组名称
'
,
'IS_DEFAULT'
=>
'是否默认
'
,
'CREATE_TIME'
=>
'创建时间
'
,
'GRADE_PERCENT'
=>
'优惠百分比
'
,
'USER_POINTS'
=>
'成为该等级所需积分
'
,
'MONEY_POINT_SRATE'
=>
'购物获得积分比率
'
,
'IS_SETRANGE'
=>
'优惠范围
'
,
];
}
/**
...
...
@@ -108,7 +110,7 @@ class ShopUserMembergrade extends BaseModel
// 'GUID',
// ];
unset
(
$fields
[
'USER_POINTS'
]);
unset
(
$fields
[
'USER_POINTS'
]
,
$fields
[
'ORG_GUID'
]
);
return
$fields
;
}
...
...
backend/models/v1/transport/ShopTransportCompany.php
View file @
9dd55ea4
...
...
@@ -54,7 +54,7 @@ class ShopTransportCompany extends BaseModel
[[
'GUID'
,
'ORG_GUID'
,
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'on'
=>
[
self
::
SCENARIO_CREATE
]],
[[
'CODE'
,
'IS_DEFAULT'
,
'NAME'
],
'required'
,
'on'
=>
[
self
::
SCENARIO_UPDATE
]],
[[
'PHONE'
],
'match'
,
'pattern'
=>
'/^1\d{10}$/'
,
'message'
=>
'手机号格式不正确'
],
[[
'IS_DEFAULT'
],
'boolean'
,
'message'
=>
'{attribute}传值错误'
],
[[
'IS_DEFAULT'
],
'boolean'
],
];
}
...
...
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