Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
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
hujun
tl_estate
Commits
47cf7f6b
Commit
47cf7f6b
authored
Aug 20, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店考勤列表-批量上传
parent
f295994c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
140 deletions
+114
-140
StoreFeeService.php
application/api_broker/service/StoreFeeService.php
+0
-36
CostParameter.php
application/index/controller/CostParameter.php
+111
-0
ReadExcel.php
application/index/controller/ReadExcel.php
+0
-82
StoreFee.php
application/index/controller/StoreFee.php
+2
-20
route.php
application/route.php
+1
-2
No files found.
application/api_broker/service/StoreFeeService.php
View file @
47cf7f6b
...
...
@@ -750,39 +750,4 @@ class StoreFeeService
}
/**
* 门店考勤列表-批量上传
* @param $file_path
* @return string
*/
public
function
readStoreFee
(
$file_path
)
{
$reader
=
new
\PhpOffice\PhpSpreadsheet\Reader\Xlsx
();
$reader
->
setReadDataOnly
(
true
);
$spreadsheet
=
""
;
try
{
$spreadsheet
=
$reader
->
load
(
$file_path
);
}
catch
(
\Exception
$exception
)
{
return
"找不到文件路径"
;
}
$sheet
=
$spreadsheet
->
getActiveSheet
();
$highestRow
=
$sheet
->
getHighestRow
();
// 最大行数
$highestColumn
=
$sheet
->
getHighestColumn
();
// 最大列数
$highestColumn
=
"AB"
;
// 把下标变成数字,如A-Z分别对应1-26,AA对应27,AB对应28,以此类推
$highestColumnIndex
=
\PhpOffice\PhpSpreadsheet\Cell\Coordinate
::
columnIndexFromString
(
$highestColumn
);
/* if($highestRow <= 2){ // 因为students.xlsx表格数据是从第三行开始的
exit('Excel没有任何数据');
}*/
$data
=
array
();
for
(
$row
=
0
;
$row
<=
$highestRow
;
$row
++
)
{
$tempData
[
'name'
]
=
$sheet
->
getCellByColumnAndRow
(
1
,
$row
)
->
getValue
();
$tempData
[
'chinese'
]
=
$sheet
->
getCellByColumnAndRow
(
2
,
$row
)
->
getValue
();
$tempData
[
'math'
]
=
$sheet
->
getCellByColumnAndRow
(
3
,
$row
)
->
getValue
();
$tempData
[
'English'
]
=
$sheet
->
getCellByColumnAndRow
(
4
,
$row
)
->
getValue
();
$data
[]
=
$tempData
;
}
dump
(
$data
);
}
}
\ No newline at end of file
application/index/controller/CostParameter.php
View file @
47cf7f6b
...
...
@@ -3,6 +3,7 @@
namespace
app\index\controller
;
use
app\api_broker\service\RedisCacheService
;
use
app\api_broker\service\UploadFileService
;
use
app\index\extend\Basic
;
use
app\api\service\ActivityService
;
use
app\index\untils\ExportExcelUntil
;
...
...
@@ -572,4 +573,113 @@ class CostParameter extends Basic
return
$this
->
response
(
"200"
,
"成功"
);
}
/**
* 门店考勤列表-批量上传
* @return \think\Response
*/
public
function
storeDataExcel
()
{
header
(
'Access-Control-Allow-Origin:*'
);
set_time_limit
(
0
);
$file
=
$_FILES
[
'file'
];
$type
=
request
()
->
param
(
'type'
);
$uploadFileService
=
new
UploadFileService
();
$uploadResult
=
$uploadFileService
->
upload
(
$file
,
$type
,
15000000
,
[
'xls'
,
'xlsx'
]);
if
(
$uploadResult
[
"code"
]
==
200
)
{
$path
=
$_FILES
[
'excel'
][
'tmp_name'
];
$result
=
$this
->
saveExcelData
(
$path
);
return
$this
->
response
(
"200"
,
"excel上传成功"
,
$uploadResult
[
"msg"
]);
}
else
{
return
$this
->
response
(
"101"
,
$uploadResult
[
"msg"
]);
}
}
/**
* 保存数据
* @param $path
* @param $setting_date
* @return bool
*/
public
function
saveExcelData
(
$path
,
$setting_date
)
{
$list
=
$this
->
readExcel
(
$path
);
if
(
!
$list
)
return
false
;
foreach
(
$list
as
$k
=>
$v
)
{
$f_params
[
'c.store_id'
]
=
$v
[
'id'
];
$f_params
[
'c.setting_date'
]
=
$setting_date
;
$f_params
[
'c.is_del'
]
=
0
;
$field
=
'a.id,a.store_name,b.office_name,d.name,d.phone,c.is_discounts,
c.transfer_charge,c.social_security_fee,c.attendance_num,c.official_receipts,
c.last_official_receipts,c.deduct'
;
$store_data_res
=
$this
->
m_store
->
getStoreCostParameter
(
$field
,
$f_params
);
if
(
!
$store_data_res
)
{
if
(
!
$v
[
'store_id'
])
continue
;
$transfer_charge
=
$this
->
getTransferCharge
(
$v
[
'store_id'
],
$setting_date
);
$list
[
$k
][
'transfer_charge'
]
=
$transfer_charge
;
//手续费
$social_security_fee
=
$this
->
getLastSocialSecurityFee
(
$v
[
'id'
],
$setting_date
);
$list
[
$k
][
'social_security_fee'
]
=
$social_security_fee
;
//当月社保报销
$list
[
$k
][
'attendance_num'
]
=
0
;
//当月考勤
$list
[
$k
][
'official_receipts'
]
=
0
;
//当月合计总实收
$list
[
$k
][
'last_official_receipts'
]
=
0
;
//当月守护者实收
$list
[
$k
][
'deduct'
]
=
0
;
//盈利不足2万扣除
$save_params
[
'store_id'
]
=
$v
[
'id'
];
$save_params
[
'setting_date'
]
=
$setting_date
;
$save_params
[
'is_del'
]
=
0
;
$save_params
[
'transfer_charge'
]
=
$transfer_charge
;
$save_params
[
'social_security_fee'
]
=
$social_security_fee
;
$this
->
saveStoreData
(
$save_params
);
}
}
return
true
;
}
/**
* 门店考勤列表-批量上传
* @param $file_path
* @return string
*/
public
function
readExcel
(
$file_path
)
{
$reader
=
new
\PhpOffice\PhpSpreadsheet\Reader\Xlsx
();
$reader
->
setReadDataOnly
(
true
);
$spreadsheet
=
""
;
try
{
$spreadsheet
=
$reader
->
load
(
$file_path
);
}
catch
(
\Exception
$exception
)
{
return
"找不到文件路径"
;
}
$sheet
=
$spreadsheet
->
getActiveSheet
();
$highestRow
=
$sheet
->
getHighestRow
();
// 最大行数
$highestColumn
=
$sheet
->
getHighestColumn
();
// 最大列数
$highestColumn
=
"AB"
;
// 把下标变成数字,如A-Z分别对应1-26,AA对应27,AB对应28,以此类推
$highestColumnIndex
=
\PhpOffice\PhpSpreadsheet\Cell\Coordinate
::
columnIndexFromString
(
$highestColumn
);
/* if($highestRow <= 2){ // 因为students.xlsx表格数据是从第三行开始的
exit('Excel没有任何数据');
}*/
$data
=
array
();
for
(
$row
=
0
;
$row
<=
$highestRow
;
$row
++
)
{
for
(
$row
=
1
;
$row
<=
$highestRow
;
$row
++
)
{
$tempData
[
'store_id'
]
=
$sheet
->
getCellByColumnAndRow
(
1
,
$row
)
->
getValue
();
$tempData
[
'social_security_fee'
]
=
$sheet
->
getCellByColumnAndRow
(
2
,
$row
)
->
getValue
();
$tempData
[
'attendance_num'
]
=
$sheet
->
getCellByColumnAndRow
(
3
,
$row
)
->
getValue
();
$tempData
[
'official_receipts'
]
=
$sheet
->
getCellByColumnAndRow
(
4
,
$row
)
->
getValue
();
$tempData
[
'last_official_receipts'
]
=
$sheet
->
getCellByColumnAndRow
(
5
,
$row
)
->
getValue
();
$tempData
[
'deduct'
]
=
$sheet
->
getCellByColumnAndRow
(
6
,
$row
)
->
getValue
();
$data
[]
=
$tempData
;
}
$data
[]
=
$tempData
;
}
return
$data
;
}
}
\ No newline at end of file
application/index/controller/ReadExcel.php
deleted
100644 → 0
View file @
f295994c
<?php
namespace
app\index\controller
;
/**
* Created by PhpStorm.
* User: zhuwei
* Date:2018-10-18
* Time:10:50:55
*/
use
app\index\extend\Basic
;
class
ReadExcel
extends
Basic
{
// protected $aSite;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
// $this->aSite = new ASite();
}
function
readExcelTest
()
{
if
(
!
empty
(
$_FILES
[
'excel'
][
'name'
]))
{
$fileName
=
$_FILES
[
'excel'
][
'name'
];
//得到文件全名
$dotArray
=
explode
(
'.'
,
$fileName
);
//把文件名安.区分,拆分成数组
$type
=
end
(
$dotArray
);
if
(
$type
!=
"xls"
&&
$type
!=
"xlsx"
)
{
$ret
[
'res'
]
=
"0"
;
$ret
[
'msg'
]
=
"不是Excel文件,请重新上传!"
;
return
json_encode
(
$ret
);
}
$path
=
$_FILES
[
'excel'
][
'tmp_name'
];
// $file = $_FILES['upload']['tmp_name'][0];
$reader
=
new
\PhpOffice\PhpSpreadsheet\Reader\Xlsx
();
$reader
->
setReadDataOnly
(
true
);
$spreadsheet
=
""
;
try
{
$spreadsheet
=
$reader
->
load
(
$path
);
}
catch
(
\Exception
$exception
)
{
return
"找不到文件路径"
;
}
$sheet
=
$spreadsheet
->
getActiveSheet
();
$highestRow
=
$sheet
->
getHighestRow
();
// 最大行数
$highestColumn
=
$sheet
->
getHighestColumn
();
// 最大列数
$highestColumn
=
"AB"
;
// 把下标变成数字,如A-Z分别对应1-26,AA对应27,AB对应28,以此类推
$highestColumnIndex
=
\PhpOffice\PhpSpreadsheet\Cell\Coordinate
::
columnIndexFromString
(
$highestColumn
);
/* if($highestRow <= 2){ // 因为students.xlsx表格数据是从第三行开始的
exit('Excel没有任何数据');
}*/
$data
=
array
();
for
(
$row
=
1
;
$row
<=
$highestRow
;
$row
++
)
{
$tempData
[
'name'
]
=
$sheet
->
getCellByColumnAndRow
(
1
,
$row
)
->
getValue
();
$tempData
[
'chinese'
]
=
$sheet
->
getCellByColumnAndRow
(
2
,
$row
)
->
getValue
();
$tempData
[
'math'
]
=
$sheet
->
getCellByColumnAndRow
(
3
,
$row
)
->
getValue
();
$tempData
[
'English'
]
=
$sheet
->
getCellByColumnAndRow
(
4
,
$row
)
->
getValue
();
$data
[]
=
$tempData
;
}
dump
(
$data
);
dump
(
$path
);
}
else
{
return
$this
->
response
(
101
,
'未上传excel'
);
}
}
}
\ No newline at end of file
application/index/controller/StoreFee.php
View file @
47cf7f6b
...
...
@@ -577,26 +577,7 @@ class StoreFee extends Basic
}
/**
* 门店考勤列表-批量上传
* @return \think\Response
*/
public
function
readStoreFee
()
{
header
(
'Access-Control-Allow-Origin:*'
);
set_time_limit
(
0
);
$file
=
$_FILES
[
'file'
];
$type
=
request
()
->
param
(
'type'
);
$uploadFileService
=
new
UploadFileService
();
$uploadResult
=
$uploadFileService
->
upload
(
$file
,
$type
,
15000000
,
[
'xls'
,
'xlsx'
]);
if
(
$uploadResult
[
"code"
]
==
200
)
{
$path
=
$_FILES
[
'excel'
][
'tmp_name'
];
$result
=
$this
->
service_
->
readStoreFee
(
$path
);
return
$this
->
response
(
"200"
,
"excel上传成功"
,
$uploadResult
[
"msg"
]);
}
else
{
return
$this
->
response
(
"101"
,
$uploadResult
[
"msg"
]);
}
}
}
\ No newline at end of file
application/route.php
View file @
47cf7f6b
...
...
@@ -577,8 +577,7 @@ Route::group('index', [
'qualityAssessment'
=>
[
'index/WorkLearning/qualityAssessment'
,
[
'method'
=>
'GET'
]],
//素质测评
'valueAssessment'
=>
[
'index/WorkLearning/valueAssessment'
,
[
'method'
=>
'GET'
]],
//价值观考核
'readExcelTest'
=>
[
'index/ReadExcel/readExcelTest'
,
[
'method'
=>
'POST'
]],
'storeDataExcel'
=>
[
'index/CostParameter/storeDataExcel'
,
[
'method'
=>
'POST'
]],
]);
...
...
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