Commit 20c90b06 authored by zhuwei's avatar zhuwei

1

parent 65b6587e
......@@ -23,9 +23,7 @@ class UploadFileService
*/
public function upload($_upload_file, $type, $size = 15000000, $ext = ['jpg', 'png', 'jpeg', 'xlsx', 'doc', 'docx', 'pdf', 'ppt', 'pptx', 'xls', 'gif', 'mp4', 'video/mp4'])
{
dump($_upload_file);
dump($type);
dump($ext);
/**
*
* upload($_FILE['file'])
......
......@@ -586,18 +586,14 @@ class CostParameter extends Basic
if(!checkTimeData($params['setting_date'])){
return $this->response("101", '非法时间');
}
// $file = $_FILES['file'];
// $type = request()->param('type');
dump($_FILES);
// $uploadFileService = new UploadFileService();
$file = $_FILES['excel_import'];
$type = $params['type']; //excel_import
$uploadFileService = new UploadFileService();
$uploadResult = $uploadFileService->upload($file, $type, 15000000, ['xls', 'xlsx']);
if ($uploadResult["code"] == 200) {
$path = $_FILES['excel_import']['tmp_name'];
$result = $this->saveExcelData($path,$params['setting_date']);
$result = $this->saveExcelData($uploadResult["msg"]["img_path"],$params['setting_date']);
if ($result["code"] == 200) {
return $this->response("200", "excel导入成功");
} else {
......@@ -620,41 +616,45 @@ class CostParameter extends Basic
if(!$list)
return ["code"=>101,"msg"=> "空excel"];
foreach ($list as $k => $v) {
dump($v);
$is_office_store = $this->m_store->getStoreCost("b.office_name", ["a.id" => $v['store_id']]);
if(!$is_office_store["office_name"]){
return ["code"=>101,"msg"=> "门店:{$v["store_id"]}不存在办公室,导入失败!"];
}
}
dump($is_office_store);exit;
$this->addStoreCost($list,$setting_date);
return ["code"=>200,"msg"=> "成功"];
$f_params['c.store_id'] = $v['id'];
}
/**
* 保存数据
* @param $list
* @param $setting_date
* @return bool
*/
public function addStoreCost($list,$setting_date){
foreach ($list as $k => $v) {
$f_params['c.store_id'] = $v['store_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';
$field = 'a.id,a.store_name';
$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);
$v['setting_date'] = $setting_date;
$v['is_del'] = 0;
$v['transfer_charge'] = $transfer_charge;
$v['social_security_fee'] = $social_security_fee;
$this->saveStoreData($v);
}
}
return ["code"=>200,"msg"=> "成功"];
return true;
}
......@@ -669,7 +669,7 @@ class CostParameter extends Basic
$reader->setReadDataOnly(true);
$spreadsheet = "";
try {
$spreadsheet = $reader->load($file_path);
$spreadsheet = $reader->load("static/excel/" .$file_path);
} catch (\Exception $exception) {
return ["code"=>101,"msg"=> "找不到文件路径"];
}
......@@ -681,7 +681,7 @@ class CostParameter extends Basic
}
$data = array();
for ($row = 0; $row <= $highestRow; $row++) {
for ($row = 1; $row <= $highestRow; $row++) {
for ($row = 3; $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();
......
......@@ -473,7 +473,6 @@ class AStore extends BaseModel
->join('f_office b', 'a.office_id = b.id', 'left')
->where($params)
->find();
dump($this->getLastSql());
return $result;
}
......
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