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
8c11d99b
Commit
8c11d99b
authored
Dec 03, 2019
by
侯贺政
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
运费模板列表加权限,运费模板详情。
Signed-off-by:
houhezheng
<
houhezheng@romens.cn
>
parent
3d30843d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
218 additions
and
10 deletions
+218
-10
urlmanager.php
backend/config/urlmanager.php
+1
-0
TransportSettingController.php
...d/controllers/v1/transport/TransportSettingController.php
+79
-3
ShopPackagingcostsBranches.php
backend/models/v1/transport/ShopPackagingcostsBranches.php
+103
-0
TransportSetting.php
backend/models/v1/transport/TransportSetting.php
+35
-7
No files found.
backend/config/urlmanager.php
View file @
8c11d99b
...
...
@@ -212,6 +212,7 @@ return [
],
'extraPatterns'
=>
[
'GET,OPTIONS transport-templates'
=>
'transport-templates'
,
'GET,OPTIONS transport-fee-details'
=>
'transport-fee-details'
,
],
],
//门店起送价设置
...
...
backend/controllers/v1/transport/TransportSettingController.php
View file @
8c11d99b
...
...
@@ -2,6 +2,11 @@
namespace
backend\controllers\v1\transport
;
use
app\models\v1\branch\ShopBranch
;
use
app\models\v1\rbacuser\ShopRbacUser
;
use
app\models\v1\transport\ShopPackagingcostsBranches
;
use
app\models\v1\shopuser\ShopUserMembergrade
;
use
app\models\v1\transport\ShopTransportType
;
use
backend\controllers\v1\BaseController
;
use
Yii
;
use
yii\web\BadRequestHttpException
;
...
...
@@ -19,10 +24,10 @@ class TransportSettingController extends BaseController
* 运费模板列表:
* 运费模板所属平台,如果不填默认取微商城的运费模板",
* @OA\Parameter(name="page",in="query",description="分页页码",@OA\Schema(type="int")),
* @OA\Parameter(name="PLATFORM_TYPE",in="query",description="运费模板所属平台(微商城:shop,积分商城:points)",@OA\Schema(type="
int
")),
* @OA\Parameter(name="PLATFORM_TYPE",in="query",description="运费模板所属平台(微商城:shop,积分商城:points)",@OA\Schema(type="
string
")),
* @OA\Response(response="200",description="
* GUID:运费模板GUID,
* TRANSPOR
_TTYP
E:配送方式,
* TRANSPOR
T_NAM
E:配送方式,
* BASE_FEE:统一费用,
* BASE_WEIGHT:首重,
* BASE_WEIGHT_FEE:首重费用,
...
...
@@ -47,10 +52,81 @@ class TransportSettingController extends BaseController
}
$list
=
$model
->
templates
(
$platform_type
);
if
(
!
$list
)
{
if
(
!
$list
->
getModels
()
)
{
throw
new
BadRequestHttpException
(
'未找到符合条件的数据'
);
}
return
$list
;
}
/**
* @OA\GET(
* path="/backend/web/v1/transport/transport-settings/transport-fee-details",
* tags={"配送管理"},
* summary="运费模板信息详情(侯贺政)",
* description="运费模板信息详情",
* @OA\Parameter(name="GUID",in="query",required=true,description="运费模板GUID",@OA\Schema(type="string")),
* @OA\Response(response="200",description="
* GUID:运费模板GUID,
* TRANSPOR_TTYPE:配送方式,
* BASE_FEE:统一费用,
* BASE_WEIGHT:首重,
* BASE_WEIGHT_FEE:首重费用,
* INCREASE_WEIGHT:续重,
* INCREASE_WEIGHT_FEE:续重费用,
* IS_USED:是否启用,
* SELECT_AREA:配送城市,
* DESCRIPTION:简介,
* LIMIT_MEMBER_GROUP_GUID:限制人群,
* GROUP_GUID:权限(所属门店GUID),
* TRANSPOR_TTYPE_ALL:所有运送方式列表
* GUID:运送方式guid,
* NAME:运送方式名称,
* LIMIT_MEMBER_GROUP_ALL:所有用户组列表
* GUID:用户组guid,
* NAME:用户组名称,
* BRANCHES_INFO:指定省级列表
* GUID:指定省级guid,
* CODE:门店编码,
* NAME:门店名称,
* IS_PERMIT:是否准许保存编辑(1:准许保存编辑,0:不准许保存编辑)"),
* security={{"Authorization":{}}}
* )
*/
public
function
actionTransportFeeDetails
()
{
$model
=
new
$this
->
modelClass
();
$model
->
GUID
=
Yii
::
$app
->
request
->
get
(
'GUID'
);
if
(
!
$model
->
validate
())
{
Yii
::
$app
->
response
->
statusCode
=
422
;
return
$model
->
errors
;
}
$info
=
$model
->
details
(
$model
->
GUID
);
if
(
!
$info
)
{
throw
new
BadRequestHttpException
(
'请求信息不存在'
);
}
$info
[
'SELECT_AREA'
]
=
explode
(
','
,
$info
[
'SELECT_AREA'
]);
$info
[
'LIMIT_MEMBER_GROUP_GUID'
]
=
explode
(
','
,
$info
[
'LIMIT_MEMBER_GROUP_GUID'
]);
$transType
=
(
new
ShopTransportType
)
->
BranchTransportInfo
();
$info
[
'TRANSPOR_TTYPE_ALL'
]
=
$transType
;
//所有运送方式
$memberGroup
=
ShopUserMembergrade
::
find
()
->
select
([
'GUID'
,
'NAME'
])
->
all
();
$info
[
'LIMIT_MEMBER_GROUP_ALL'
]
=
$memberGroup
;
//所有用户组
$transportBranches
=
(
new
ShopPackagingcostsBranches
)
->
transportBranches
(
$model
->
GUID
);
$info
[
'BRANCHES_INFO'
]
=
$transportBranches
;
//指定省级
//权限
$permit
=
1
;
$branchInfo
=
ShopBranch
::
find
()
->
select
([
'BRANCH_TYPE'
,
'SUPPROVINCE_GUID'
])
->
where
([
'GUID'
=>
$info
[
'GROUP_GUID'
]]);
$userInfo
=
(
new
ShopRbacUser
)
->
getRbacUserInfo
(
Yii
::
$app
->
user
->
identity
->
GUID
);
//总部权限管理员1,分部管理员权限2,门店权限3。非权限内不可保存编辑
if
(
!
in_array
(
$userInfo
[
'ROLE_ID'
],
[
1
,
2
]))
{
$permit
=
0
;
}
//分部管理员权限2,分部管理员所属上级与运送模板创建所属上级不一致时不准保存编辑
if
(
$userInfo
[
'ROLE_ID'
]
==
USER_ROLE_REGION_ADMIN
&&
$userInfo
[
'SUPPROVINCE_GUID'
]
!=
$branchInfo
[
'SUPPROVINCE_GUID'
])
{
$permit
=
0
;
}
$info
[
'IS_PERMIT'
]
=
$permit
;
//是否准许编辑保存,1:准许保存编辑,0:禁止保存编辑
return
$info
;
}
}
backend/models/v1/transport/ShopPackagingcostsBranches.php
0 → 100644
View file @
8c11d99b
<?php
namespace
app\models\v1\transport
;
use
Yii
;
/**
* This is the model class for table "shop_packagingcosts_branches".
*
* @property string $GUID
* @property string|null $ORG_GUID 组织机构号
* @property string|null $ACTIVITY_GUID 包装费guid
* @property string|null $BRANCH_GUID 门店guid
* @property string|null $ACTIVITY_TYPE 活动类型,包装费(PACKAGING_COSTS)
* @property string|null $CREATE_TIME 添加时间
* @property string|null $YGROUP_CODE
*/
class
ShopPackagingcostsBranches
extends
\app\models\v1\BaseModel
{
public
$CODE
;
//门店编码
public
$NAME
;
//门店名称
/**
* {@inheritdoc}
*/
public
static
function
tableName
()
{
return
'shop_packagingcosts_branches'
;
}
/**
* {@inheritdoc}
*/
public
function
rules
()
{
return
[
[[
'GUID'
],
'required'
],
[[
'CREATE_TIME'
],
'safe'
],
[[
'GUID'
,
'ORG_GUID'
,
'ACTIVITY_GUID'
,
'BRANCH_GUID'
,
'ACTIVITY_TYPE'
,
'YGROUP_CODE'
],
'string'
,
'max'
=>
50
],
[[
'GUID'
],
'unique'
],
];
}
/**
* {@inheritdoc}
*/
public
function
attributeLabels
()
{
return
[
'GUID'
=>
'Guid'
,
'ORG_GUID'
=>
'Org Guid'
,
'ACTIVITY_GUID'
=>
'Activity Guid'
,
'BRANCH_GUID'
=>
'Branch Guid'
,
'ACTIVITY_TYPE'
=>
'Activity Type'
,
'CREATE_TIME'
=>
'Create Time'
,
'YGROUP_CODE'
=>
'Ygroup Code'
,
];
}
/**
* {@inheritdoc}
*/
public
function
extraFields
()
{
return
[
'CODE'
,
//门店编码
'NAME'
,
//门店名称
];
}
/**
* 获取指定省级
*
* @params string $guid 运费模板GUID
* @return array|null 返回指定省级
*/
public
function
transportBranches
(
$guid
)
{
$query
=
static
::
find
()
->
alias
(
's'
)
->
select
([
's.GUID'
,
'sb.CODE'
,
'sb.NAME'
])
->
leftJoin
(
'SHOP_BRANCH sb'
,
's.BRANCH_GUID=sb.GUID'
)
->
where
([
's.ACTIVITY_TYPE'
=>
'TRANSPORTFEE'
,
's.ACTIVITY_GUID'
=>
$guid
])
->
orderBy
([
's.GUID'
=>
SORT_ASC
])
->
all
();
$list
=
[];
foreach
(
$query
as
$request
)
{
$list
[]
=
$request
->
toArray
([],
[
'CODE'
,
'NAME'
]);
}
return
$list
;
}
/**
* 根据权限获取省级对应的hopPackagingcostsBranches
*
* @return array|null 返回运费模板GUID列表
*/
public
static
function
transportSetting
(
$branchGuid
)
{
$query
=
static
::
find
()
->
select
([
'ACTIVITY_GUID'
])
->
where
([
'ACTIVITY_TYPE'
=>
'TRANSPORTFEE'
,
'BRANCH_GUID'
=>
$branchGuid
])
->
all
();
return
$query
;
}
}
backend/models/v1/transport/TransportSetting.php
View file @
8c11d99b
...
...
@@ -3,9 +3,9 @@
namespace
app\models\v1\transport
;
use
app\models\v1\common\ShopTransportArea
;
use
app\models\v1\rbacuser\ShopRbacUser
;
use
Yii
;
use
yii\data\ActiveDataProvider
;
use
yii\debug\models\timeline\DataProvider
;
/**
* This is the model class for table "shop_transport_setting".
...
...
@@ -25,7 +25,7 @@ use yii\debug\models\timeline\DataProvider;
* @property int|null $IS_USED 是否启用
* @property string $PLATFORM_TYPE 运费模板所属平台(shop,points)默认shop
* @property string|null $LIMIT_MEMBER_GROUP_GUID 限制人群
* @property string|null $GROUP_GUID 权限
* @property string|null $GROUP_GUID 权限
(所属门店)
*/
class
TransportSetting
extends
\app\models\v1\BaseModel
{
...
...
@@ -74,7 +74,7 @@ class TransportSetting extends \app\models\v1\BaseModel
'IS_USED'
=>
'是否启用'
,
'PLATFORM_TYPE'
=>
'运费模板所属平台'
,
'LIMIT_MEMBER_GROUP_GUID'
=>
'限制人群'
,
'GROUP_GUID'
=>
'权限'
,
'GROUP_GUID'
=>
'权限
(所属门店)
'
,
];
}
...
...
@@ -84,12 +84,24 @@ class TransportSetting extends \app\models\v1\BaseModel
* @params string $platform_type 运费模板所属平台
* @return array|null 返回运费模板列表
*/
public
function
templates
(
$platform_type
)
public
function
templates
(
$platform_type
,
$where
=
[]
)
{
$userInfo
=
(
new
ShopRbacUser
)
->
getRbacUserInfo
(
Yii
::
$app
->
user
->
identity
->
GUID
);
//省级权限,只展示省级所属的信息
if
(
$userInfo
[
'ROLE_ID'
]
==
2
)
{
$array
=
ShopPackagingcostsBranches
::
transportSetting
(
$userInfo
[
'BRANCH_GUID'
]);
$activityGUID
=
[];
foreach
(
$array
as
$key
=>
$value
)
{
$activityGUID
[]
=
$value
[
'ACTIVITY_GUID'
];
}
$where
=
[
'ts.GUID'
=>
$activityGUID
];
}
$query
=
static
::
find
()
->
alias
(
'ts'
)
->
select
([
'ts.GUID'
,
'stt.NAME as TRANSPORT_NAME'
,
'ts.BASE_FEE'
,
'ts.BASE_WEIGHT'
,
'ts.BASE_WEIGHT_FEE'
,
'ts.IS_USED'
,
'ts.SELECT_AREA'
])
->
leftJoin
(
'shop_transport_type stt'
,
'ts.TRANSPOR_TTYPE=stt.GUID'
)
->
where
([
'ts.PLATFORM_TYPE'
=>
$platform_type
]);
->
where
([
'ts.PLATFORM_TYPE'
=>
$platform_type
])
->
andWhere
(
$where
);
$dataProvider
=
new
ActiveDataProvider
([
'query'
=>
$query
->
asArray
(),
...
...
@@ -107,11 +119,27 @@ class TransportSetting extends \app\models\v1\BaseModel
$area
=
ShopTransportArea
::
findAll
([
"GUID"
=>
$citys
]);
$area_name
=
[];
foreach
(
$area
as
$v
)
{
$area_name
[]
=
$v
[
'NAME'
];
$area_name
[]
=
$v
[
'NAME'
];
}
$temp
[
$key
][
'SELECT_AREA'
]
=
implode
(
','
,
$area_name
);
$temp
[
$key
][
'SELECT_AREA'
]
=
implode
(
','
,
$area_name
);
}
$dataProvider
->
setModels
(
$temp
);
return
$dataProvider
;
}
/**
* 运费模板详情
*
* @params string $guid 运费模板guid
* @return array|null 返回运费模板详情
*/
public
function
details
(
$guid
)
{
$info
=
static
::
find
()
->
select
([
'GUID'
,
'TRANSPOR_TTYPE'
,
'BASE_FEE'
,
'BASE_WEIGHT'
,
'BASE_WEIGHT_FEE'
,
'INCREASE_WEIGHT'
,
'INCREASE_WEIGHT_FEE'
,
'DESCRIPTION'
,
'SELECT_AREA'
,
'IS_USED'
,
'LIMIT_MEMBER_GROUP_GUID'
,
'GROUP_GUID'
])
->
where
([
'GUID'
=>
$guid
])
->
asArray
()
->
one
();
return
$info
;
}
}
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