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
1d5c1244
Commit
1d5c1244
authored
Dec 13, 2019
by
侯贺政
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导入门店打分评价,批量验证门店。优化省份获取
Signed-off-by:
houhezheng
<
houhezheng@romens.cn
>
parent
d460c4db
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
28 deletions
+23
-28
BranchScoreController.php
backend/controllers/v1/branch/BranchScoreController.php
+8
-12
ShopEmployeeController.php
backend/controllers/v1/shopuser/ShopEmployeeController.php
+1
-1
ShopBranch.php
backend/models/v1/branch/ShopBranch.php
+12
-10
ShopTransportArea.php
backend/models/v1/common/ShopTransportArea.php
+2
-5
No files found.
backend/controllers/v1/branch/BranchScoreController.php
View file @
1d5c1244
...
...
@@ -371,7 +371,13 @@ class BranchScoreController extends BaseController
return
$fileInfo
[
'INFO'
];
}
$arr
=
Helper
::
newSpreadsheet
(
$fileInfo
[
'INFO'
][
0
])
->
getRows
(
false
,
[
'rowOffset'
=>
1
,
'columns'
=>
10
]);
$data
=
Helper
::
newSpreadsheet
(
$fileInfo
[
'INFO'
][
0
])
->
getRows
(
false
,
[
'rowOffset'
=>
1
,
'columns'
=>
10
]);
$arr
=
(
new
ShopBranch
)
->
validateBranch
(
$data
,
0
);
//批量验证门店
if
(
isset
(
$arr
[
'CODE'
]))
{
@
unlink
(
$fileInfo
[
'INFO'
][
0
]);
Yii
::
$app
->
response
->
statusCode
=
422
;
return
$arr
[
'list'
];
}
$model
=
new
$this
->
modelClass
();
$model
->
scenario
=
'update'
;
$transaction
=
$model
->
getDb
()
->
beginTransaction
();
...
...
@@ -379,16 +385,6 @@ class BranchScoreController extends BaseController
if
(
is_array
(
$arr
)
&&
!
empty
(
$arr
))
{
try
{
foreach
(
$arr
as
$key
=>
$value
)
{
//判断是否存在该门店
$branchMolde
=
ShopBranch
::
findOne
([
'CODE'
=>
$value
[
0
]]);
if
(
!
$branchMolde
)
{
$returnInfo
=
[
(
$key
+
1
)
=>
[
'error'
=>
'不存在该门店,检查并更正门店编码,或删除此条数据'
]
];
@
unlink
(
$fileInfo
[
'INFO'
][
0
]);
Yii
::
$app
->
response
->
statusCode
=
422
;
return
$returnInfo
;
}
$_model
=
$model
::
findOne
([
'BRANCH_CODE'
=>
$value
[
0
]]);
if
(
$_model
===
null
)
{
$_model
=
clone
$model
;
...
...
@@ -405,7 +401,7 @@ class BranchScoreController extends BaseController
$_model
->
ARTIFICIAL_NUMBER
=
(
string
)
$value
[
8
];
$_model
->
ARTIFICIAL_NAME
=
$value
[
9
];
$_model
->
UPDATE_TIME
=
date
(
'Y-m-d H:i:s'
,
time
());
$_model
->
BRANCH_NAME
=
$
branchMolde
[
'
NAME'
];
$_model
->
BRANCH_NAME
=
$
value
[
'BRANCH_
NAME'
];
if
(
!
$_model
->
save
())
{
$transaction
->
rollBack
();
$returnInfo
=
[
...
...
backend/controllers/v1/shopuser/ShopEmployeeController.php
View file @
1d5c1244
...
...
@@ -137,7 +137,7 @@ class ShopEmployeeController extends BaseController
}
$data
=
Helper
::
newSpreadsheet
(
$fileInfo
[
'INFO'
][
0
])
->
getRows
(
true
,
[
'rowOffset'
=>
2
,
'columns'
=>
9
]);
$arr
=
(
new
ShopBranch
)
->
validateBranch
(
$data
);
$arr
=
(
new
ShopBranch
)
->
validateBranch
(
$data
,
8
);
if
(
isset
(
$arr
[
'CODE'
]))
{
@
unlink
(
$fileInfo
[
'INFO'
][
0
]);
Yii
::
$app
->
response
->
statusCode
=
422
;
...
...
backend/models/v1/branch/ShopBranch.php
View file @
1d5c1244
...
...
@@ -508,12 +508,13 @@ class ShopBranch extends BaseModel
* 如果验证成功,则给每条数据,带入所属门店的GUID。
*
* @param array $arr 需要验证的数据
* @param int $num 门店CODE所在位置
* @return array
*/
public
function
validateBranch
(
$arr
)
public
function
validateBranch
(
$arr
,
$num
)
{
$userInfo
=
(
new
ShopRbacUser
)
->
getRbacUserInfo
(
Yii
::
$app
->
user
->
identity
->
GUID
);
//
删除条件:总部权限删除所有,省级只能删除自己。
//
权限省级权限不能跨省级;不能跨门店操作
$where
=
[];
switch
(
$userInfo
[
'ROLE_ID'
])
{
case
USER_ROLE_REGION_ADMIN
:
//省级
...
...
@@ -527,20 +528,21 @@ class ShopBranch extends BaseModel
break
;
}
$branches
=
static
::
find
()
->
select
(
'CODE,GUID'
)
->
andFilterwhere
(
$where
)
->
asArray
()
->
all
();
$branchesCode
=
array_column
(
$branches
,
'CODE'
);
$branches
=
static
::
find
()
->
select
(
'CODE,GUID
,NAME
'
)
->
andFilterwhere
(
$where
)
->
asArray
()
->
all
();
$branchesCode
=
array_column
(
$branches
,
'CODE'
);
foreach
(
$arr
as
$key
=>
$value
)
{
if
(
in_array
(
$value
[
8
],
$branchesCode
))
{
if
(
!
in_array
(
$value
[
$num
],
$branchesCode
))
{
$value
[
'error'
]
=
'门店编码不正确,检查并更正所属门店编码,或删除此条数据'
;
$list
[
$key
+
1
]
=
$value
;
$list
[
$key
+
1
]
=
$value
;
}
//获取当前员工的门店GUID
$branch
=
array_search
(
$value
[
8
],
$branchesCode
);
$arr
[
$key
][
'BRANCH_GUID'
]
=
$branch
?
$branches
[
$branch
][
'GUID'
]
:
''
;
//获取此条数据所属的门店GUID,NAME
$branch
=
array_search
(
$value
[
$num
],
$branchesCode
);
$arr
[
$key
][
'BRANCH_GUID'
]
=
$branch
?
$branches
[
$branch
][
'GUID'
]
:
''
;
$arr
[
$key
][
'BRANCH_NAME'
]
=
$branch
?
$branches
[
$branch
][
'NAME'
]
:
''
;
}
if
(
isset
(
$list
))
{
return
[
'CODE'
=>
'422'
,
'list'
=>
$list
];
return
[
'CODE'
=>
'422'
,
'list'
=>
$list
];
}
return
$arr
;
}
...
...
backend/models/v1/common/ShopTransportArea.php
View file @
1d5c1244
...
...
@@ -61,10 +61,7 @@ class ShopTransportArea extends BaseModel
public
function
getProvinces
(
$citys
=
[])
{
$_citys
=
static
::
findAll
([
'GUID'
=>
$citys
]);
$provinces
=
[];
foreach
(
$_citys
as
$value
)
{
$provinces
[]
=
$value
[
'PARENT_GUID'
];
}
return
array_keys
(
array_flip
(
$provinces
));
$provinces
=
array_column
(
$_citys
,
'PARENT_GUID'
);
return
array_values
(
array_unique
(
$provinces
));
}
}
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