Commit 40c2ae78 authored by 孙磊's avatar 孙磊

导入优化

Signed-off-by: 孙磊's avatarsunlei <sunlei@romens.cn>
parent 1d5c1244
......@@ -251,7 +251,7 @@ class BranchServiceTypeController extends BaseController
*/
public function actionBranchServiceImport()
{
$model = new UploadFiles();
$model = new UploadFiles(['xlsx', 'xls']);
if (Yii::$app->request->isPost) {
//多文件用getInstances
$model->uploadFiles = UploadedFile::getInstance($model, 'uploadFile');
......@@ -298,6 +298,10 @@ class BranchServiceTypeController extends BaseController
throw $e;
}
} else {
Yii::$app->response->statusCode = 422;
if ($fileInfo['INFO']['uploadFiles'][0] == "类型不对") {
$fileInfo['INFO']['uploadFiles'][0] = '文件类型要求97-2003工作簿 xls格式!';
}
return $fileInfo['INFO'];
}
}
......
......@@ -168,7 +168,7 @@ class TransportInitialPriceController extends BaseController
*/
public function actionInitialPriceImport()
{
$model = new UploadFiles();
$model = new UploadFiles(['xlsx', 'xls']);
if (Yii::$app->request->isPost) {
//多文件用getInstances
$model->uploadFiles = UploadedFile::getInstance($model, 'uploadFile');
......@@ -179,6 +179,15 @@ class TransportInitialPriceController extends BaseController
// 文件上传成功
$rows = Helper::newSpreadsheet($fileInfo['INFO'][0])->getRows();
$tempArr = array_slice($rows, 2);
//批量验证门店
$branchModel = new ShopBranch();
$branch_info = $branchModel->validateBranch($tempArr, 0);
//若不存在的门店 则返回相关信息
if (isset($branch_info['CODE'])) {
@unlink($fileInfo['INFO'][0]);
Yii::$app->response->statusCode = 422;
return $branch_info['list'];
}
$citydisregion = new $this->modelClass();
$citydisregion->scenario = 'import';
$transaction = $citydisregion->getDb()->beginTransaction();
......@@ -189,24 +198,24 @@ class TransportInitialPriceController extends BaseController
$_citydisregion = $citydisregion->getBranchInitialPrice('', $CS_BRANCH_GUID);
// $_citydisregion = $citydisregion->getBranchInitialPrice('', 003);
//权限信息
$rbac = new ShopRbacUser();
$userGuid = Yii::$app->user->identity->GUID;
$userinfo = $rbac->getRbacUserInfo($userGuid);
// $rbac = new ShopRbacUser();
// $userGuid = Yii::$app->user->identity->GUID;
// $userinfo = $rbac->getRbacUserInfo($userGuid);
//return $userinfo;
//判断当前账号是省级还是门店还是总部
if ($userinfo['ROLE_ID'] == USER_ROLE_REGION_ADMIN) {
//如果是省级,查询出该门店是否是该省级下的
$branchModel = new ShopBranch();
$isbrancharr = $branchModel->GetBranch($CS_BRANCH_GUID, $userinfo['BRANCH_GUID']);
// $isbrancharr = $branchModel->GetBranch(003, 003);
if (!$isbrancharr) {
continue;
}
} else if ($userinfo['ROLE_ID'] == USER_ROLE_STORE_ADMIN) { //如果是门店
if ($userinfo['BRANCH_GUID'] != $CS_BRANCH_GUID) {
continue;
}
}
// if ($userinfo['ROLE_ID'] == USER_ROLE_REGION_ADMIN) {
// //如果是省级,查询出该门店是否是该省级下的
// $branchModel = new ShopBranch();
// $isbrancharr = $branchModel->GetBranch($CS_BRANCH_GUID, $userinfo['BRANCH_GUID']);
// // $isbrancharr = $branchModel->GetBranch(003, 003);
// if (!$isbrancharr) {
// continue;
// }
// } else if ($userinfo['ROLE_ID'] == USER_ROLE_STORE_ADMIN) { //如果是门店
// if ($userinfo['BRANCH_GUID'] != $CS_BRANCH_GUID) {
// continue;
// }
// }
//修改已有的起送价设置
if (!$list = $_citydisregion->getModels()) {
continue;
......@@ -237,6 +246,10 @@ class TransportInitialPriceController extends BaseController
throw $e;
}
} else {
Yii::$app->response->statusCode = 422;
if ($fileInfo['INFO']['uploadFiles'][0] == "类型不对") {
$fileInfo['INFO']['uploadFiles'][0] = '文件类型要求97-2003工作簿 xls格式!';
}
return $fileInfo['INFO'];
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment