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