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
caafce37
Commit
caafce37
authored
Aug 20, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
80d6a149
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
51 deletions
+84
-51
StoreFeeService.php
application/api_broker/service/StoreFeeService.php
+38
-27
StoreFee.php
application/index/controller/StoreFee.php
+29
-23
AStore.php
application/model/AStore.php
+1
-1
FApplyForFee.php
application/model/FApplyForFee.php
+16
-0
No files found.
application/api_broker/service/StoreFeeService.php
View file @
caafce37
...
@@ -154,7 +154,6 @@ class StoreFeeService
...
@@ -154,7 +154,6 @@ class StoreFeeService
private
function
applyForFeeBin
(
$id
,
$type
,
$fee_item
,
$total_fee
,
$agent_id
,
$store_id
,
$purpose
,
$site_id
,
$card_name
,
private
function
applyForFeeBin
(
$id
,
$type
,
$fee_item
,
$total_fee
,
$agent_id
,
$store_id
,
$purpose
,
$site_id
,
$card_name
,
$bank
,
$card_no
,
$count_time
,
$office_id
,
$status
,
$source
=
0
)
$bank
,
$card_no
,
$count_time
,
$office_id
,
$status
,
$source
=
0
)
{
{
$arr
=
[];
$arr
=
[];
if
(
$type
)
{
if
(
$type
)
{
$arr
[
"type"
]
=
$type
;
$arr
[
"type"
]
=
$type
;
...
@@ -711,42 +710,54 @@ class StoreFeeService
...
@@ -711,42 +710,54 @@ class StoreFeeService
public
function
importStoreFee
(
$file_path
)
public
function
importStoreFee
(
$file_path
)
{
{
echo
111
;
$reader
=
new
\PhpOffice\PhpSpreadsheet\Reader\Xlsx
();
$reader
=
new
\PhpOffice\PhpSpreadsheet\Reader\Xlsx
();
$reader
->
setReadDataOnly
(
true
);
$reader
->
setReadDataOnly
(
true
);
$spreadsheet
=
""
;
$spreadsheet
=
""
;
try
{
try
{
$spreadsheet
=
$reader
->
load
(
"static/excel/"
.
$file_path
);
$spreadsheet
=
$reader
->
load
(
"static/excel/"
.
$file_path
);
}
catch
(
\Exception
$exception
)
{
}
catch
(
\Exception
$exception
)
{
return
"找不到文件路径"
;
return
[
"code"
=>
101
,
"msg"
=>
"找不到文件路径"
]
;
}
}
$sheet
=
$spreadsheet
->
getActiveSheet
();
$sheet
=
$spreadsheet
->
getActiveSheet
();
$highestRow
=
$sheet
->
getHighestRow
();
// 最大行数
$highestRow
=
$sheet
->
getHighestRow
();
// 最大行数
$highestColumn
=
$sheet
->
getHighestColumn
();
// 最大列数
if
(
$highestRow
<=
2
)
{
$highestColumn
=
"AB"
;
return
[
"code"
=>
101
,
"msg"
=>
"Excel没有任何数据"
];
// 把下标变成数字,如A-Z分别对应1-26,AA对应27,AB对应28,以此类推
}
$highestColumnIndex
=
\PhpOffice\PhpSpreadsheet\Cell\Coordinate
::
columnIndexFromString
(
$highestColumn
);
/* if($highestRow <= 2){ // 因为students.xlsx表格数据是从第三行开始的
exit('Excel没有任何数据');
}*/
$data
=
array
();
$data
=
array
();
for
(
$row
=
0
;
$row
<=
$highestRow
;
$row
++
)
{
$storeModel
=
new
AStore
();
$type
=
$sheet
->
getCellByColumnAndRow
(
1
,
$row
)
->
getValue
();
for
(
$row
=
3
;
$row
<=
$highestRow
;
$row
++
)
{
$fee_item
=
$sheet
->
getCellByColumnAndRow
(
2
,
$row
)
->
getValue
();
$count_time
=
$sheet
->
getCellByColumnAndRow
(
1
,
$row
)
->
getValue
();
$total_fee
=
$sheet
->
getCellByColumnAndRow
(
3
,
$row
)
->
getValue
();
$toTimestamp
=
\PhpOffice\PhpSpreadsheet\Shared\Date
::
excelToTimestamp
(
$count_time
);
$agent_id
=
$sheet
->
getCellByColumnAndRow
(
4
,
$row
)
->
getValue
();
$date
=
date
(
"Y-m-01"
,
$toTimestamp
);
$store_id
=
$sheet
->
getCellByColumnAndRow
(
5
,
$row
)
->
getValue
();
$total_fee
=
$sheet
->
getCellByColumnAndRow
(
2
,
$row
)
->
getValue
();
$purpose
=
$sheet
->
getCellByColumnAndRow
(
6
,
$row
)
->
getValue
();
$type
=
$sheet
->
getCellByColumnAndRow
(
3
,
$row
)
->
getValue
();
$site_id
=
$sheet
->
getCellByColumnAndRow
(
7
,
$row
)
->
getValue
();
$fee_item
=
$sheet
->
getCellByColumnAndRow
(
4
,
$row
)
->
getValue
();
$card_name
=
$sheet
->
getCellByColumnAndRow
(
8
,
$row
)
->
getValue
();
$purpose
=
$sheet
->
getCellByColumnAndRow
(
5
,
$row
)
->
getValue
();
$bank
=
$sheet
->
getCellByColumnAndRow
(
9
,
$row
)
->
getValue
();
$store_id
=
$sheet
->
getCellByColumnAndRow
(
6
,
$row
)
->
getValue
();
$card_no
=
$sheet
->
getCellByColumnAndRow
(
10
,
$row
)
->
getValue
();
$count_time
=
$sheet
->
getCellByColumnAndRow
(
11
,
$row
)
->
getValue
();
$if_verify
=
$this
->
verifyType
((
int
)
$type
,
(
int
)
$fee_item
);
$office_id
=
$sheet
->
getCellByColumnAndRow
(
12
,
$row
)
->
getValue
();
if
(
!
$if_verify
)
{
array_push
(
$data
,
$this
->
applyForFeeBin
(
$type
,
$fee_item
,
$total_fee
,
$agent_id
,
$store_id
,
$purpose
,
$site_id
,
$card_name
,
return
[
"code"
=>
101
,
"msg"
=>
"类型选择错误"
];
$bank
,
$card_no
,
$count_time
,
$office_id
,
0
,
1
,
1
));
}
}
dump
(
$data
);
$storeInfo
=
$storeModel
->
getStoreById
(
$store_id
);
if
(
!
$storeInfo
||
!
$storeInfo
[
"agents_id"
]
||
!
$storeInfo
[
"site_id"
])
{
return
[
"code"
=>
101
,
"msg"
=>
"门店信息错误"
];
}
$agent_id
=
$storeInfo
[
"agents_id"
];
$site_id
=
$storeInfo
[
"site_id"
];
$office_id
=
$storeInfo
[
"office_id"
];
array_push
(
$data
,
$this
->
applyForFeeBin
(
0
,
$type
,
$fee_item
,
$total_fee
,
$agent_id
,
$store_id
,
$purpose
,
$site_id
,
""
,
""
,
""
,
$date
,
$office_id
,
0
,
1
));
}
if
(
$data
){
$applyForModel
=
new
FApplyForFee
();
$is_ok
=
$applyForModel
->
addData
(
$data
);
return
[
"code"
=>
200
,
"msg"
=>
"
$is_ok
"
];
}
return
[
"code"
=>
101
,
"msg"
=>
"未知异常"
];
}
}
...
...
application/index/controller/StoreFee.php
View file @
caafce37
...
@@ -56,21 +56,21 @@ class StoreFee extends Basic
...
@@ -56,21 +56,21 @@ class StoreFee extends Basic
// 验证用户数据
// 验证用户数据
$cache
=
new
RedisCacheService
();
$cache
=
new
RedisCacheService
();
$agent_info
=
$cache
->
getRedisCache
(
2
,
$agent_id
);
$agent_info
=
$cache
->
getRedisCache
(
2
,
$agent_id
);
if
(
!
$agent_info
)
{
if
(
!
$agent_info
)
{
return
$this
->
response
(
"101"
,
"用户不存在 "
);
return
$this
->
response
(
"101"
,
"用户不存在 "
);
}
}
$agent_name
=
$agent_info
[
"name"
];
$agent_name
=
$agent_info
[
"name"
];
// 1.判断是否都审核过,
// 1.判断是否都审核过,
$is_check
=
$this
->
service_
->
verifyCheck
(
$setting_date
);
$is_check
=
$this
->
service_
->
verifyCheck
(
$setting_date
);
if
(
!
$is_check
)
{
if
(
!
$is_check
)
{
return
$this
->
response
(
"101"
,
"请先审核所有设置数据然后再提交一键生成! "
);
return
$this
->
response
(
"101"
,
"请先审核所有设置数据然后再提交一键生成! "
);
}
}
// 2.计算门店成本 3.总部成本,4.分部成本,5.同联发展基金 6门店单独成本
// 2.计算门店成本 3.总部成本,4.分部成本,5.同联发展基金 6门店单独成本
$msg
=
$this
->
service_
->
calculateStoreFee
(
$setting_date
,
$agent_id
,
$agent_name
);
$msg
=
$this
->
service_
->
calculateStoreFee
(
$setting_date
,
$agent_id
,
$agent_name
);
if
(
$msg
!=
1
)
{
if
(
$msg
!=
1
)
{
return
$this
->
response
(
"101"
,
$msg
);
return
$this
->
response
(
"101"
,
$msg
);
}
else
{
}
else
{
return
$this
->
response
(
"200"
,
"success"
);
return
$this
->
response
(
"200"
,
"success"
);
}
}
}
}
...
@@ -78,7 +78,8 @@ class StoreFee extends Basic
...
@@ -78,7 +78,8 @@ class StoreFee extends Basic
/**
/**
* @return \think\Response
* @return \think\Response
*/
*/
public
function
getCost
(){
public
function
getCost
()
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
/* $params = array(
/* $params = array(
"setting_date" => "2019-06-01",
"setting_date" => "2019-06-01",
...
@@ -88,10 +89,10 @@ class StoreFee extends Basic
...
@@ -88,10 +89,10 @@ class StoreFee extends Basic
}
}
$setting_date
=
$params
[
"setting_date"
];
$setting_date
=
$params
[
"setting_date"
];
$result
=
$this
->
service_
->
getCost
(
$setting_date
);
$result
=
$this
->
service_
->
getCost
(
$setting_date
);
if
(
$result
)
{
if
(
$result
)
{
return
$this
->
response
(
"200"
,
"当月已提交过一键生成,是否重新提交覆盖原来的数据?"
);
return
$this
->
response
(
"200"
,
"当月已提交过一键生成,是否重新提交覆盖原来的数据?"
);
}
else
{
}
else
{
return
$this
->
response
(
"101"
,
"暂未生成
$setting_date
数据"
);
return
$this
->
response
(
"101"
,
"暂未生成
$setting_date
数据"
);
}
}
}
}
...
@@ -101,7 +102,8 @@ class StoreFee extends Basic
...
@@ -101,7 +102,8 @@ class StoreFee extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getStoreFeeDetail
(){
public
function
getStoreFeeDetail
()
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
/* $params = array(
/* $params = array(
"setting_date" => "2019-06-01",
"setting_date" => "2019-06-01",
...
@@ -113,29 +115,33 @@ class StoreFee extends Basic
...
@@ -113,29 +115,33 @@ class StoreFee extends Basic
$setting_date
=
$params
[
"setting_date"
];
$setting_date
=
$params
[
"setting_date"
];
$store_id
=
$params
[
"store_id"
];
$store_id
=
$params
[
"store_id"
];
$result
=
$this
->
service_
->
getStoreFeeDetail
(
$setting_date
,
$store_id
);
$result
=
$this
->
service_
->
getStoreFeeDetail
(
$setting_date
,
$store_id
);
if
(
$result
)
{
if
(
$result
)
{
return
$this
->
response
(
"200"
,
"success"
,
$result
);
return
$this
->
response
(
"200"
,
"success"
,
$result
);
}
else
{
}
else
{
return
$this
->
response
(
"101"
,
"暂未生成
$setting_date
数据"
);
return
$this
->
response
(
"101"
,
"暂未生成
$setting_date
数据"
);
}
}
}
}
public
function
importStoreFee
()
public
function
importStoreFee
()
{
{
header
(
'Access-Control-Allow-Origin:*'
);
header
(
'Access-Control-Allow-Origin:*'
);
/*
set_time_limit(0);
set_time_limit
(
0
);
$file
=
$_FILES
[
'file'
];
$file
=
$_FILES
[
'file'
];
$type
=
request
()
->
param
(
'type'
);
//excel_import
$type
=
request
()
->
param
(
'type'
);
//excel_import
$uploadFileService
=
new
UploadFileService
();
$uploadFileService
=
new
UploadFileService
();
$uploadResult
=
$uploadFileService
->
upload
(
$file
,
$type
,
15000000
,
[
'xls'
,
'xlsx'
]);
$uploadResult
=
$uploadFileService
->
upload
(
$file
,
$type
,
15000000
,
[
'xls'
,
'xlsx'
]);
if ($uploadResult["code"] == 200) {*/
if
(
$uploadResult
[
"code"
]
==
200
)
{
// $result = $this->service_->importStoreFee($uploadResult["msg"]);
$result
=
$this
->
service_
->
importStoreFee
(
$uploadResult
[
"msg"
][
"img_path"
]);
$result
=
$this
->
service_
->
importStoreFee
(
"20190820/20190820110629513.xlsx"
);
if
(
$result
[
"code"
]
==
200
)
{
/* return $this->response("200", "excel上传成功", $uploadResult["msg"]);
return
$this
->
response
(
"200"
,
"excel导入成功"
);
}
else
{
return
$this
->
response
(
"101"
,
$result
[
"msg"
]);
}
}
else
{
}
else
{
return
$this
->
response
(
"101"
,
$uploadResult
[
"msg"
]);
return
$this
->
response
(
"101"
,
$uploadResult
[
"msg"
]);
}
*/
}
}
}
/**
/**
...
@@ -484,7 +490,7 @@ class StoreFee extends Basic
...
@@ -484,7 +490,7 @@ class StoreFee extends Basic
//不验证 1办公室成本 2总部成本
//不验证 1办公室成本 2总部成本
if
(
$params
[
'fee_item'
]
==
3
||
$params
[
'fee_item'
]
==
4
)
{
if
(
$params
[
'fee_item'
]
==
3
||
$params
[
'fee_item'
]
==
4
)
{
$if_verify
=
$service_
->
verifyType
(
$type
,
$fee_item
);
$if_verify
=
$service_
->
verifyType
(
$type
,
$fee_item
);
if
(
!
$if_verify
)
{
if
(
!
$if_verify
)
{
return
$this
->
response
(
"101"
,
"类型选择错误"
);
return
$this
->
response
(
"101"
,
"类型选择错误"
);
}
}
}
}
...
...
application/model/AStore.php
View file @
caafce37
...
@@ -118,7 +118,7 @@ class AStore extends BaseModel
...
@@ -118,7 +118,7 @@ class AStore extends BaseModel
public
function
getStoreById
(
$id
)
{
public
function
getStoreById
(
$id
)
{
$data
=
$this
->
where
(
'id'
,
$id
)
->
where
(
'status'
,
0
)
->
find
();
$data
=
$this
->
where
(
'id'
,
$id
)
->
where
(
'status'
,
0
)
->
find
();
$agents
=
new
AAgents
();
$agents
=
new
AAgents
();
$agents_name
=
$agents
->
field
(
'id,name,phone'
)
->
where
(
'store_id'
,
$data
[
'id'
])
->
where
(
'level'
,
'in'
,[
20
,
40
])
->
find
();
$agents_name
=
$agents
->
field
(
'id,name,phone
,site_id
'
)
->
where
(
'store_id'
,
$data
[
'id'
])
->
where
(
'level'
,
'in'
,[
20
,
40
])
->
find
();
$data
[
'district_name'
]
=
Db
::
table
(
'a_district'
)
->
where
(
'id'
,
$data
[
'district_id'
])
->
value
(
'district_name'
);
$data
[
'district_name'
]
=
Db
::
table
(
'a_district'
)
->
where
(
'id'
,
$data
[
'district_id'
])
->
value
(
'district_name'
);
$data
[
'agents_id'
]
=
$agents_name
[
'id'
];
$data
[
'agents_id'
]
=
$agents_name
[
'id'
];
$data
[
'agents_name'
]
=
$agents_name
[
'name'
]
.
'-'
.
$agents_name
[
'phone'
];
$data
[
'agents_name'
]
=
$agents_name
[
'name'
]
.
'-'
.
$agents_name
[
'phone'
];
...
...
application/model/FApplyForFee.php
View file @
caafce37
...
@@ -27,6 +27,22 @@ class FApplyForFee extends BaseModel
...
@@ -27,6 +27,22 @@ class FApplyForFee extends BaseModel
$id
=
$this
->
db_
->
insertGetId
(
$data
);
$id
=
$this
->
db_
->
insertGetId
(
$data
);
return
$id
;
return
$id
;
}
}
/**
* @param $params
* @return int
*/
public
function
addData
(
$params
)
{
Db
::
startTrans
();
try
{
$this
->
db_
->
insertAll
(
$params
);
Db
::
commit
();
return
1
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
0
;
}
}
/**
/**
* @param $data
* @param $data
...
...
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