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
737962ba
Commit
737962ba
authored
Jul 23, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
5767d450
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
383 additions
and
96 deletions
+383
-96
StoreFeeService.php
application/api_broker/service/StoreFeeService.php
+186
-25
StoreFee.php
application/index/controller/StoreFee.php
+73
-60
FApplyForFee.php
application/model/FApplyForFee.php
+16
-0
FCompanyData.php
application/model/FCompanyData.php
+14
-0
FStoreCost.php
application/model/FStoreCost.php
+31
-9
FStoreData.php
application/model/FStoreData.php
+63
-2
No files found.
application/api_broker/service/StoreFeeService.php
View file @
737962ba
...
@@ -3,7 +3,10 @@
...
@@ -3,7 +3,10 @@
namespace
app\api_broker\service
;
namespace
app\api_broker\service
;
use
app\model\FApplyForFee
;
use
app\model\FApplyForFee
;
use
app\model\FCompanyData
;
use
app\model\FImg
;
use
app\model\FImg
;
use
app\model\FStoreCost
;
use
app\model\FStoreData
;
/**
/**
* Created by PhpStorm.
* Created by PhpStorm.
...
@@ -160,18 +163,18 @@ class StoreFeeService
...
@@ -160,18 +163,18 @@ class StoreFeeService
{
{
$image_array
=
explode
(
','
,
$id_string
);
$image_array
=
explode
(
','
,
$id_string
);
$result
[
'status'
]
=
'fail'
;
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
''
;
$result
[
'msg'
]
=
''
;
if
(
!
is_array
(
$image_array
)
&&
!
is_numeric
(
$id_string
))
{
if
(
!
is_array
(
$image_array
)
&&
!
is_numeric
(
$id_string
))
{
$result
[
'msg'
]
=
'参数错误'
;
$result
[
'msg'
]
=
'参数错误'
;
return
$result
;
return
$result
;
}
}
$img_data
=
$this
->
imgModel
->
findByAll
(
'id,img_name'
,
[
'id'
=>
[
'in'
,
$id_string
]]);
$img_data
=
$this
->
imgModel
->
findByAll
(
'id,img_name'
,
[
'id'
=>
[
'in'
,
$id_string
]]);
$num
=
0
;
$num
=
0
;
$path
=
ROOT_PATH
.
'public/'
;
$path
=
ROOT_PATH
.
'public/'
;
foreach
(
$img_data
as
$v
)
{
foreach
(
$img_data
as
$v
)
{
$num
+=
$this
->
imgModel
->
editData
([
'i
mg_status'
=>
1
],
$v
[
'id'
]);
$num
+=
$this
->
imgModel
->
editData
([
'i
s_del'
=>
1
],
$v
[
'id'
]);
@
unlink
(
$path
.
'static/chat_image/'
.
$v
[
'img_name'
]);
@
unlink
(
$path
.
'static/chat_image/'
.
$v
[
'img_name'
]);
}
}
if
(
$num
)
{
if
(
$num
)
{
...
@@ -182,30 +185,187 @@ class StoreFeeService
...
@@ -182,30 +185,187 @@ class StoreFeeService
return
$result
;
return
$result
;
}
}
/**
public
function
calculateStoreFee
(
$setting_date
,
$agent_id
,
$agent_name
)
* 新增费用审核
*
* @param $data
* @param $img_id
* @return int|string
*/
public
function
saveImageData
(
$data
,
$img_id
)
{
{
$num
=
0
;
$storeCostModel
=
new
FStoreCost
();
foreach
(
$data
as
$k
=>
$v
)
{
$storeCostModel
->
updateCost
([
"status"
=>
1
],
[
"setting_date"
=>
$setting_date
]);
// 修改掉之前的全部失效
if
(
empty
(
$v
))
{
$id
=
$storeCostModel
->
addCost
(
continue
;
$this
->
storeCostBin
(
$setting_date
,
$agent_id
,
$agent_name
)
);
if
(
$id
>
0
)
{
$this
->
creationStoreFeeDetail
(
$id
,
$setting_date
);
}
return
false
;
}
public
function
creationStoreFeeDetail
(
$cost_id
,
$setting_date
)
{
$storeSettingInfo
=
$this
->
getStoreData
(
$setting_date
);
if
(
!
$storeSettingInfo
)
{
return
"当月门店数据未设置"
;
}
$companyDataInfo
=
$this
->
getCompanyData
(
$setting_date
);
if
(
!
$companyDataInfo
)
{
return
"当月公司数据未设置"
;
}
//todo 计算公司总考勤数 和分部考勤数
$companyAttendanceNum
=
$this
->
sumAttendanceNum
(
0
,
1
,
$setting_date
);
$districtAttendanceNum
=
$this
->
sumAttendanceNum
(
0
,
2
,
$setting_date
);
foreach
(
$storeSettingInfo
as
$key
=>
$item
)
{
$applyForFeeArr
=
$this
->
getApplyForFee
(
$item
[
"store_id"
],
$setting_date
);
//门店
$insertArr
=
[];
if
(
$applyForFeeArr
)
{
foreach
(
$applyForFeeArr
as
$k
=>
$value
)
{
$type
=
$value
[
"type"
];
$fee_item
=
$value
[
"fee_item"
];
$attendance_num
=
$value
[
"attendance_num"
];
//门店参与考勤人数
$apply_for_id
=
$value
[
"id"
];
$apply_for_time
=
$value
[
"create_time"
];
$total_fee
=
$value
[
"total_fee"
];
$store_id
=
$value
[
"old_store_id"
];
$office_id
=
$value
[
"old_office_id"
];
$officeAttendanceNum
=
$this
->
sumAttendanceNum
(
$office_id
,
3
,
$setting_date
);
//办公室参与考勤人数
$purpose
=
$value
[
"purpose"
];
switch
(
$value
[
"type"
])
{
case
1
://
办公室成本
$assume_fee
=
ceil
(
$attendance_num
/
$officeAttendanceNum
*
100
)
*
$total_fee
*
0.01
;
break
;
case
2
:
//公司总考勤减去所有计算折扣的门店人数
if
(
$item
[
"is_discounts"
]
==
1
){
$attendance_num
=
$value
[
"attendance_num"
]
/
2
;
$assume_fee
=
ceil
(
$attendance_num
/
$officeAttendanceNum
-
12312
*
100
)
*
$total_fee
*
0.01
;
}
break
;
case
3
:
break
;
case
4
:
break
;
}
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
));
}
}
}
//insert
$save_data
[
$k
][
'img_id'
]
=
$img_id
;
$save_data
[
$k
][
'img_name'
]
=
$v
;
$save_data
[
$k
][
'img_type'
]
=
1
;
}
}
}
if
(
isset
(
$save_data
))
{
/**
$num
=
$this
->
imgModel
->
insertDataAll
(
$save_data
);
* @param $id
* @param $type
* @param $setting_date
* @return float|int
*/
private
function
sumAttendanceNum
(
$id
,
$type
,
$setting_date
)
{
$storeDataModel
=
new
FStoreData
();
$params
[
"is_del"
]
=
0
;
$params
[
"setting_date"
]
=
$setting_date
;
switch
(
$type
)
{
case
1
://
公司
return
$storeDataModel
->
sumCompanyAttendance
(
$params
);
case
2
://
分部
return
$storeDataModel
->
sumDistrictAttendance
(
$params
);
case
3
://
办公室
$params
[
"office_id"
]
=
$id
;
return
$storeDataModel
->
sumOfficeAttendance
(
$params
);
}
}
return
0
;
}
return
$num
;
private
function
storeCostExtBin
(
$cost_id
,
$type
,
$fee_item
,
$apply_for_id
,
$apply_for_time
,
$total_fee
,
$store_attendance_num
,
$office_attendance_num
,
$district_attendance_num
,
$total_attendance_num
,
$assume_fee
,
$purpose
)
{
$arr
=
[];
$arr
[
"cost_id"
]
=
$cost_id
;
$arr
[
"type"
]
=
$type
;
$arr
[
"fee_item"
]
=
$fee_item
;
$arr
[
"apply_for_id"
]
=
$apply_for_id
;
$arr
[
"apply_for_time"
]
=
$apply_for_time
;
$arr
[
"total_fee"
]
=
$total_fee
;
$arr
[
"store_attendance_num"
]
=
$store_attendance_num
;
$arr
[
"office_attendance_num"
]
=
$office_attendance_num
;
$arr
[
"district_attendance_num"
]
=
$district_attendance_num
;
$arr
[
"total_attendance_num"
]
=
$total_attendance_num
;
$arr
[
"assume_fee"
]
=
$assume_fee
;
$arr
[
"purpose"
]
=
$purpose
;
return
$arr
;
}
}
/**
* @param $store_id
* @param $setting_date
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private
function
getApplyForFee
(
$store_id
,
$setting_date
)
{
$applyForFeeModel
=
new
FApplyForFee
();
$field
=
"a.id,a.type,a.fee_item,a.purpose,a.total_fee,a.office_id,a.agent_id,a.store_id,a.assume_fee,
a.status,a.count_time,a.site_id,a.create_time,b.id as old_store_id,b.office_id as old_office_id"
;
$params
[
"b.id"
]
=
$store_id
;
$params
[
"a.count_time"
]
=
$setting_date
;
$params
[
"a.is_del"
]
=
0
;
$params
[
"a.status"
]
=
4
;
return
$applyForFeeModel
->
getApplyForFeeList
(
$field
,
$params
);
}
/**
* @param $setting_date
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private
function
getStoreData
(
$setting_date
)
{
$storeDataModel
=
new
FStoreData
();
$field
=
"id,setting_date,type,fixed_fee,apply_for_fee,discounts"
;
$params
[
"is_del"
]
=
0
;
$params
[
"setting_date"
]
=
$setting_date
;
return
$storeDataModel
->
selectStoreFee
(
$field
,
$params
);
}
/**
* @param $setting_date
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private
function
getCompanyData
(
$setting_date
)
{
$companyData
=
new
FCompanyData
();
$field
=
"id,store_id,setting_date,is_discounts,social_security_fee,attendance_num,official_receipts,
last_official_receipts,deduct,transfer_charge"
;
$params
[
"is_del"
]
=
0
;
$params
[
"setting_date"
]
=
$setting_date
;
return
$companyData
->
selectCompanyData
(
$field
,
$params
);
}
/**
* @param $setting_date
* @param $agent_id
* @param $agent_name
* @return array
*/
private
function
storeCostBin
(
$setting_date
,
$agent_id
,
$agent_name
)
{
$arr
=
[];
$arr
[
"setting_date"
]
=
$setting_date
;
$arr
[
"operator_id"
]
=
$agent_id
;
$arr
[
"operator_name"
]
=
$agent_name
;
$arr
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$arr
[
"update_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
return
$arr
;
}
}
}
\ No newline at end of file
application/index/controller/StoreFee.php
View file @
737962ba
<?php
<?php
namespace
app\index\controller
;
namespace
app\index\controller
;
/**
/**
* Created by PhpStorm.
* Created by PhpStorm.
...
@@ -8,6 +9,7 @@ namespace app\index\controller;
...
@@ -8,6 +9,7 @@ namespace app\index\controller;
*/
*/
use
app\api_broker\service\RedisCacheService
;
use
app\api_broker\service\StoreFeeService
;
use
app\api_broker\service\StoreFeeService
;
use
app\api_broker\validate\StoreFeeValidate
;
use
app\api_broker\validate\StoreFeeValidate
;
use
app\index\extend\Basic
;
use
app\index\extend\Basic
;
...
@@ -20,7 +22,7 @@ class StoreFee extends Basic
...
@@ -20,7 +22,7 @@ class StoreFee extends Basic
{
{
protected
$f_office
;
protected
$f_office
;
private
$service_
;
private
$service_
;
public
function
__construct
(
$request
=
null
)
public
function
__construct
(
$request
=
null
)
{
{
...
@@ -29,22 +31,32 @@ class StoreFee extends Basic
...
@@ -29,22 +31,32 @@ class StoreFee extends Basic
$this
->
service_
=
new
StoreFeeService
();
$this
->
service_
=
new
StoreFeeService
();
}
}
public
function
createStoreFee
(){
public
function
creationStoreFee
()
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
$params
=
array
(
$params
=
array
(
"setting_date"
=>
"2019-06-01"
,
"setting_date"
=>
"2019-06-01"
,
"agent_id"
=>
1
,
"agent_id"
=>
1
,
);
);
if
(
!
$params
[
"setting_date"
]
||
!
$params
[
"agent_id"
])
{
if
(
!
$params
[
"setting_date"
]
||
!
$params
[
"agent_id"
])
{
return
$this
->
response
(
"101"
,
"请求参数错误 "
);
return
$this
->
response
(
"101"
,
"请求参数错误 "
);
}
}
$setting_date
=
$params
[
"setting_date"
];
$setting_date
=
$params
[
"setting_date"
];
$agent_id
=
$params
[
"agent_id"
];
$agent_id
=
$params
[
"agent_id"
];
//todo 验证用户数据
$cache
=
new
RedisCacheService
();
$agent_info
=
$cache
->
getRedisCache
(
2
,
$agent_id
);
if
(
!
$agent_info
){
return
$this
->
response
(
"101"
,
"用户不存在 "
);
}
$agent_name
=
$agent_info
[
"name"
];
//todo 1.判断是否都审核过,
//todo 1.判断是否都审核过,
//todo 2.计算门店成本 3.总部成本,4.分部成本,5.同联发展基金 6门店单独成本
//todo 2.计算门店成本 3.总部成本,4.分部成本,5.同联发展基金 6门店单独成本
$this
->
service_
->
calculateStoreFee
(
$setting_date
,
$agent_id
);
$this
->
service_
->
calculateStoreFee
(
$setting_date
,
$agent_id
,
$agent_name
);
}
}
/**
/**
...
@@ -67,16 +79,16 @@ class StoreFee extends Basic
...
@@ -67,16 +79,16 @@ class StoreFee extends Basic
return
$this
->
response
(
"101"
,
$checkResult
);
return
$this
->
response
(
"101"
,
$checkResult
);
}
}
$office
=
$this
->
getOffice
(
'id'
,
[
'office_name'
=>
$params
[
'office_name'
]]);
$office
=
$this
->
getOffice
(
'id'
,
[
'office_name'
=>
$params
[
'office_name'
]]);
if
(
$office
)
{
if
(
$office
)
{
return
$this
->
response
(
"101"
,
'已存在该办公室!'
);
return
$this
->
response
(
"101"
,
'已存在该办公室!'
);
}
}
$data
[
"site_id"
]
=
$params
[
'site_id'
];
$data
[
"site_id"
]
=
$params
[
'site_id'
];
$data
[
"office_name"
]
=
$params
[
'office_name'
];
$data
[
"office_name"
]
=
$params
[
'office_name'
];
$data
[
"office_address"
]
=
$params
[
'office_address'
];
$data
[
"office_address"
]
=
$params
[
'office_address'
];
$data
[
"rent"
]
=
$params
[
'rent'
];
$data
[
"rent"
]
=
$params
[
'rent'
];
$data
[
"operator_id"
]
=
$this
->
userId
;
$data
[
"operator_id"
]
=
$this
->
userId
;
$result
=
$this
->
f_office
->
saveOffice
(
$data
);
//int(1)
$result
=
$this
->
f_office
->
saveOffice
(
$data
);
//int(1)
...
@@ -109,7 +121,7 @@ class StoreFee extends Basic
...
@@ -109,7 +121,7 @@ class StoreFee extends Basic
return
$this
->
response
(
"101"
,
$checkResult
);
return
$this
->
response
(
"101"
,
$checkResult
);
}
}
$office
=
$this
->
getOffice
(
'id'
,
[
'id'
=>
$params
[
'id'
]]);
$office
=
$this
->
getOffice
(
'id'
,
[
'id'
=>
$params
[
'id'
]]);
if
(
!
$office
)
{
if
(
!
$office
)
{
return
$this
->
response
(
"101"
,
'不存在该办公室!'
);
return
$this
->
response
(
"101"
,
'不存在该办公室!'
);
}
}
...
@@ -131,19 +143,19 @@ class StoreFee extends Basic
...
@@ -131,19 +143,19 @@ class StoreFee extends Basic
"office_name" => '鳖'
"office_name" => '鳖'
"office_address" => '上海市黄浦区龙华东路800号'
"office_address" => '上海市黄浦区龙华东路800号'
);*/
);*/
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
$conditions
=
[];
$conditions
=
[];
if
(
!
empty
(
$params
[
'office_name'
]))
{
if
(
!
empty
(
$params
[
'office_name'
]))
{
$conditions
[
'office_name'
]
=
[
'LIKE'
,
'%'
.
$params
[
'office_name'
]
.
'%'
];
$conditions
[
'office_name'
]
=
[
'LIKE'
,
'%'
.
$params
[
'office_name'
]
.
'%'
];
}
}
if
(
!
empty
(
$params
[
'office_address'
]))
{
if
(
!
empty
(
$params
[
'office_address'
]))
{
$conditions
[
'office_address'
]
=
[
'LIKE'
,
'%'
.
$params
[
'office_address'
]
.
'%'
];
$conditions
[
'office_address'
]
=
[
'LIKE'
,
'%'
.
$params
[
'office_address'
]
.
'%'
];
}
}
$field
=
'id,rent,office_name,office_address,create_time,site_id
'
;
$field
=
'id,rent,office_name,office_address,create_time
'
;
$result
=
$this
->
f_office
->
getOffice
(
$field
,
$conditions
,
$pageNo
,
$pageSize
);
$result
=
$this
->
f_office
->
getOffice
(
$field
,
$conditions
,
$pageNo
,
$pageSize
);
if
(
!
$result
)
if
(
!
$result
)
return
$this
->
response
(
"200"
,
"成功"
,
[]);
return
$this
->
response
(
"200"
,
"成功"
,
[]);
$m_store
=
new
AStore
();
$m_store
=
new
AStore
();
...
@@ -151,8 +163,8 @@ class StoreFee extends Basic
...
@@ -151,8 +163,8 @@ class StoreFee extends Basic
$result
[
$k
][
'store_num'
]
=
$m_store
->
getOfficeStore
(
$v
[
'id'
]);
//办公室门店数
$result
[
$k
][
'store_num'
]
=
$m_store
->
getOfficeStore
(
$v
[
'id'
]);
//办公室门店数
}
}
$result_total
=
$this
->
f_office
->
getOfficeTotal
(
$field
,
$conditions
);
$result_total
=
$this
->
f_office
->
getOfficeTotal
(
$field
,
$conditions
);
$data
[
'list'
]
=
$result
;
$data
[
'list'
]
=
$result
;
$data
[
'total'
]
=
$result_total
;
$data
[
'total'
]
=
$result_total
;
return
$this
->
response
(
"200"
,
"成功"
,
$data
);
return
$this
->
response
(
"200"
,
"成功"
,
$data
);
}
}
...
@@ -174,8 +186,8 @@ class StoreFee extends Basic
...
@@ -174,8 +186,8 @@ class StoreFee extends Basic
return
$this
->
response
(
"101"
,
$checkResult
);
return
$this
->
response
(
"101"
,
$checkResult
);
}
}
$conditions
[
'id'
]
=
$params
[
'id'
];
$conditions
[
'id'
]
=
$params
[
'id'
];
$field
=
'id,rent,site_id,office_name,office_address'
;
$field
=
'id,rent,site_id,office_name,office_address'
;
$result
=
$this
->
f_office
->
findByOne
(
$field
,
$conditions
);
$result
=
$this
->
f_office
->
findByOne
(
$field
,
$conditions
);
if
(
!
$result
)
{
if
(
!
$result
)
{
return
$this
->
response
(
"101"
,
'此办公室不存在'
);
return
$this
->
response
(
"101"
,
'此办公室不存在'
);
}
}
...
@@ -190,7 +202,7 @@ class StoreFee extends Basic
...
@@ -190,7 +202,7 @@ class StoreFee extends Basic
* @param $conditions
* @param $conditions
* @return array|false|\PDOStatement|string|\think\Model
* @return array|false|\PDOStatement|string|\think\Model
*/
*/
public
function
getOffice
(
$field
,
$conditions
)
public
function
getOffice
(
$field
,
$conditions
)
{
{
$result
=
$this
->
f_office
->
findByOne
(
$field
,
$conditions
);
$result
=
$this
->
f_office
->
findByOne
(
$field
,
$conditions
);
return
$result
;
return
$result
;
...
@@ -210,22 +222,22 @@ class StoreFee extends Basic
...
@@ -210,22 +222,22 @@ class StoreFee extends Basic
if
(
true
!==
$checkResult
)
{
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
return
$this
->
response
(
"101"
,
$checkResult
);
}
}
$office
=
$this
->
getOffice
(
'id'
,
[
'id'
=>
$params
[
'id'
]]);
$office
=
$this
->
getOffice
(
'id'
,
[
'id'
=>
$params
[
'id'
]]);
if
(
!
$office
)
{
if
(
!
$office
)
{
return
$this
->
response
(
"101"
,
'不存在该办公室!'
);
return
$this
->
response
(
"101"
,
'不存在该办公室!'
);
}
}
$m_store
=
new
AStore
();
$m_store
=
new
AStore
();
$store_params
[
'office_id'
]
=
$params
[
'id'
];
$store_params
[
'office_id'
]
=
$params
[
'id'
];
$store_field
=
'id,store_name'
;
$store_field
=
'id,store_name'
;
$store_result
=
$m_store
->
getStore
(
$store_params
,
$store_field
);
$store_result
=
$m_store
->
getStore
(
$store_params
,
$store_field
);
if
(
!
$store_result
)
{
if
(
!
$store_result
)
{
return
$this
->
response
(
"200"
,
"成功"
,
[]);
return
$this
->
response
(
"200"
,
"成功"
,
[]);
}
}
foreach
(
$store_result
as
$k
=>
$v
)
{
foreach
(
$store_result
as
$k
=>
$v
)
{
$people_num_list
=
$this
->
getPeopleListAndNum
(
$v
[
'id'
]);
$people_num_list
=
$this
->
getPeopleListAndNum
(
$v
[
'id'
]);
$store_result
[
$k
][
'people_num'
]
=
$people_num_list
[
'people_num'
];
$store_result
[
$k
][
'people_num'
]
=
$people_num_list
[
'people_num'
];
$store_result
[
$k
][
'people_list'
]
=
$people_num_list
[
'people_list'
];
$store_result
[
$k
][
'people_list'
]
=
$people_num_list
[
'people_list'
];
}
}
...
@@ -240,12 +252,12 @@ class StoreFee extends Basic
...
@@ -240,12 +252,12 @@ class StoreFee extends Basic
*/
*/
public
function
getPeopleListAndNum
(
$store_id
)
public
function
getPeopleListAndNum
(
$store_id
)
{
{
$params
=
[];
$params
=
[];
$params
[
"store_id"
]
=
$store_id
;
$params
[
"store_id"
]
=
$store_id
;
$params
[
"status"
]
=
0
;
$params
[
"status"
]
=
0
;
$m_agent
=
new
AAgents
();
$m_agent
=
new
AAgents
();
$m_agent_res
=
$m_agent
->
getAgentsByStoreId
(
$params
);
$m_agent_res
=
$m_agent
->
getAgentsByStoreId
(
$params
);
$people_num
=
count
(
$m_agent_res
);
$people_num
=
count
(
$m_agent_res
);
$people_list
=
""
;
$people_list
=
""
;
if
(
$people_num
>
0
)
{
if
(
$people_num
>
0
)
{
...
@@ -256,7 +268,7 @@ class StoreFee extends Basic
...
@@ -256,7 +268,7 @@ class StoreFee extends Basic
}
}
$return
[
'people_list'
]
=
$people_list
;
$return
[
'people_list'
]
=
$people_list
;
$return
[
'people_num'
]
=
$people_num
;
$return
[
'people_num'
]
=
$people_num
;
return
$return
;
return
$return
;
}
}
...
@@ -279,26 +291,26 @@ class StoreFee extends Basic
...
@@ -279,26 +291,26 @@ class StoreFee extends Basic
$m_store
=
new
AStore
();
$m_store
=
new
AStore
();
$store_result
=
$m_store
->
getStore
([
'id'
=>
$params
[
'store_id'
]],
'id'
);
$store_result
=
$m_store
->
getStore
([
'id'
=>
$params
[
'store_id'
]],
'id'
);
if
(
!
$store_result
)
if
(
!
$store_result
)
return
$this
->
response
(
"101"
,
"该门店不存在"
);
return
$this
->
response
(
"101"
,
"该门店不存在"
);
if
(
$params
[
'office_id'
]
==
0
)
{
if
(
$params
[
'office_id'
]
==
0
)
{
//解绑
//解绑
$conditions
[
'office_id'
]
=
0
;
$conditions
[
'office_id'
]
=
0
;
$conditions
[
'id'
]
=
$params
[
'store_id'
];
$conditions
[
'id'
]
=
$params
[
'store_id'
];
$return
=
$m_store
->
updateStore
(
$conditions
);
$return
=
$m_store
->
updateStore
(
$conditions
);
}
else
{
}
else
{
$store_params
[
'id'
]
=
$params
[
'store_id'
];
$store_params
[
'id'
]
=
$params
[
'store_id'
];
$store_params
[
'office_id'
]
=
array
(
'gt'
,
0
);
$store_params
[
'office_id'
]
=
array
(
'gt'
,
0
);
$store_result
=
$m_store
->
getStore
(
$store_params
,
'id'
);
$store_result
=
$m_store
->
getStore
(
$store_params
,
'id'
);
if
(
$store_result
)
if
(
$store_result
)
return
$this
->
response
(
"101"
,
"该门店已绑定或已绑定其他办公室"
);
return
$this
->
response
(
"101"
,
"该门店已绑定或已绑定其他办公室"
);
//绑定
//绑定
$conditions
[
'id'
]
=
$params
[
'store_id'
];
$conditions
[
'id'
]
=
$params
[
'store_id'
];
$conditions
[
'office_id'
]
=
$params
[
'office_id'
];
$conditions
[
'office_id'
]
=
$params
[
'office_id'
];
$return
=
$m_store
->
updateStore
(
$conditions
);
$return
=
$m_store
->
updateStore
(
$conditions
);
}
}
return
$this
->
response
(
"200"
,
"成功"
,
$return
);
return
$this
->
response
(
"200"
,
"成功"
,
$return
);
...
@@ -319,16 +331,16 @@ class StoreFee extends Basic
...
@@ -319,16 +331,16 @@ class StoreFee extends Basic
$conditions
=
[];
$conditions
=
[];
if
(
!
empty
(
$params
[
'store_name'
]))
{
if
(
!
empty
(
$params
[
'store_name'
]))
{
$conditions
[
'store_name'
]
=
[
'LIKE'
,
'%'
.
$params
[
'store_name'
]
.
'%'
];
$conditions
[
'store_name'
]
=
[
'LIKE'
,
'%'
.
$params
[
'store_name'
]
.
'%'
];
}
}
$m_store
=
new
AStore
();
$m_store
=
new
AStore
();
$store_field
=
'id,store_name'
;
$store_field
=
'id,store_name'
;
$store_result
=
$m_store
->
getStore
(
$conditions
,
$store_field
);
$store_result
=
$m_store
->
getStore
(
$conditions
,
$store_field
);
if
(
!
$store_result
)
if
(
!
$store_result
)
return
$this
->
response
(
"101"
,
"成功"
,[]);
return
$this
->
response
(
"101"
,
"成功"
,
[]);
return
$this
->
response
(
"200"
,
"成功"
,
$store_result
);
return
$this
->
response
(
"200"
,
"成功"
,
$store_result
);
}
}
/**
/**
...
@@ -354,14 +366,14 @@ class StoreFee extends Basic
...
@@ -354,14 +366,14 @@ class StoreFee extends Basic
'img_arr' => [],//数组模式 同收款一样
'img_arr' => [],//数组模式 同收款一样
);*/
);*/
$check_url
=
ltrim
(
$this
->
request
->
baseUrl
(),
'/'
);
$check_url
=
ltrim
(
$this
->
request
->
baseUrl
(),
'/'
);
$validate
=
new
StoreFeeValidate
();
$validate
=
new
StoreFeeValidate
();
$id
=
0
;
$id
=
0
;
if
(
$check_url
==
'index/addApplyFor'
)
{
if
(
$check_url
==
'index/addApplyFor'
)
{
$checkResult
=
$validate
->
scene
(
"addApplyFor"
)
->
check
(
$params
);
$checkResult
=
$validate
->
scene
(
"addApplyFor"
)
->
check
(
$params
);
}
else
{
}
else
{
$id
=
$params
[
'id'
];
$id
=
$params
[
'id'
];
$checkResult
=
$validate
->
scene
(
"editApplyFor"
)
->
check
(
$params
);
$checkResult
=
$validate
->
scene
(
"editApplyFor"
)
->
check
(
$params
);
}
}
if
(
true
!==
$checkResult
)
{
if
(
true
!==
$checkResult
)
{
...
@@ -383,7 +395,7 @@ class StoreFee extends Basic
...
@@ -383,7 +395,7 @@ class StoreFee extends Basic
if
(
!
$img_arr
&&
$check_url
==
'index/addApplyFor'
)
{
if
(
!
$img_arr
&&
$check_url
==
'index/addApplyFor'
)
{
return
$this
->
response
(
"101"
,
"请上传图片"
);
return
$this
->
response
(
"101"
,
"请上传图片"
);
}
}
$service_
=
new
StoreFeeService
();
$service_
=
new
StoreFeeService
();
//不验证 1办公室成本 2总部成本
//不验证 1办公室成本 2总部成本
if
(
$params
[
'fee_item'
]
==
3
||
$params
[
'fee_item'
]
==
4
)
{
if
(
$params
[
'fee_item'
]
==
3
||
$params
[
'fee_item'
]
==
4
)
{
...
@@ -409,17 +421,18 @@ class StoreFee extends Basic
...
@@ -409,17 +421,18 @@ class StoreFee extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getApplyForFeeStore
(){
public
function
getApplyForFeeStore
()
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
/* $params = array(
/* $params = array(
"store_id" => 1
"store_id" => 1
);*/
);*/
$storeModel
=
new
AStore
();
$storeModel
=
new
AStore
();
$field
=
"a.id,b.office_address"
;
$field
=
"a.id,b.office_address"
;
$office_info
=
$storeModel
->
getStoreAndOffice
(
$field
,
[
"store_id"
=>
$params
[
"store_id"
]]);
$office_info
=
$storeModel
->
getStoreAndOffice
(
$field
,
[
"store_id"
=>
$params
[
"store_id"
]]);
if
(
$office_info
)
{
if
(
$office_info
)
{
return
$this
->
response
(
"200"
,
"request success"
,
$office_info
);
return
$this
->
response
(
"200"
,
"request success"
,
$office_info
);
}
else
{
}
else
{
return
$this
->
response
(
"101"
,
"null"
);
return
$this
->
response
(
"101"
,
"null"
);
}
}
}
}
...
...
application/model/FApplyForFee.php
View file @
737962ba
...
@@ -78,6 +78,22 @@ class FApplyForFee extends BaseModel
...
@@ -78,6 +78,22 @@ class FApplyForFee extends BaseModel
->
where
(
$params
)
->
where
(
$params
)
->
count
(
'a.id'
);
->
count
(
'a.id'
);
}
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getApplyForFeeList
(
$field
,
$params
){
return
$this
->
db_
->
field
(
$field
)
->
alias
(
"a"
)
->
join
(
"f_apply_for_fee b"
,
"a.store_id = b.id"
,
"left"
)
->
where
(
$params
)
->
select
();
}
/**
/**
* @param $field
* @param $field
...
...
application/model/FCompanyData.php
View file @
737962ba
...
@@ -60,4 +60,18 @@ class FCompanyData extends BaseModel
...
@@ -60,4 +60,18 @@ class FCompanyData extends BaseModel
{
{
return
$this
->
db_
->
update
(
$params
);
return
$this
->
db_
->
update
(
$params
);
}
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
selectCompanyData
(
$field
,
$params
){
return
$this
->
db_
->
field
(
$field
)
->
where
(
$params
)
->
select
();
}
}
}
application/model/FStoreCost.php
View file @
737962ba
...
@@ -18,16 +18,38 @@ class FStoreCost extends BaseModel
...
@@ -18,16 +18,38 @@ class FStoreCost extends BaseModel
/**
/**
* 新增数据
* @param $params
* @param $data
* @return int
* @return mixed
*/
*/
public
function
saveOffice
(
$data
)
{
public
function
addCost
(
$params
)
$time
=
date
(
"Y-m-d H:i:s"
,
time
());
{
$data
[
"is_del"
]
=
0
;
Db
::
startTrans
();
$data
[
'create_time'
]
=
$time
;
try
{
$data
[
'update_time'
]
=
$time
;
$id
=
$this
->
db_
->
insertGetId
(
$params
);
return
$this
->
db_
->
insert
(
$data
);
Db
::
commit
();
return
$id
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
0
;
}
}
/**
* @param $where
* @param $params
* @return int
*/
public
function
updateCost
(
$where
,
$params
)
{
Db
::
startTrans
();
try
{
$this
->
where
(
$where
)
->
update
(
$params
);
Db
::
commit
();
return
1
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
0
;
}
}
}
/**
/**
...
...
application/model/FStoreData.php
View file @
737962ba
...
@@ -35,6 +35,9 @@ class FStoreData extends BaseModel
...
@@ -35,6 +35,9 @@ class FStoreData extends BaseModel
* @param $field
* @param $field
* @param $params
* @param $params
* @return array|false|\PDOStatement|string|Model
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
*/
public
function
findByOne
(
$field
,
$params
)
{
public
function
findByOne
(
$field
,
$params
)
{
$result
=
$this
->
db_
$result
=
$this
->
db_
...
@@ -44,13 +47,71 @@ class FStoreData extends BaseModel
...
@@ -44,13 +47,71 @@ class FStoreData extends BaseModel
return
$result
;
return
$result
;
}
}
/**
/**更新数据
* 更新数据
* @param $params
* @param $params
* @return int|string
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
*/
public
function
updateStoreData
(
$params
)
public
function
updateStoreData
(
$params
)
{
{
return
$this
->
db_
->
update
(
$params
);
return
$this
->
db_
->
update
(
$params
);
}
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
selectStoreFee
(
$field
,
$params
){
return
$this
->
db_
->
field
(
$field
)
->
where
(
$params
)
->
select
();
}
public
function
sumCompanyAttendance
(
$params
){
return
$this
->
db_
->
field
(
"sum(attendance_num) as num"
)
->
where
(
$params
)
->
select
();
}
public
function
sumDistrictAttendance
(
$params
){
$where_
=
[];
if
(
isset
(
$params
[
"is_del"
])){
$where_
[
"a.is_del"
]
=
$params
[
"is_del"
];
}
if
(
isset
(
$params
[
"setting_date"
])){
$where_
[
"a.setting_date"
]
=
$params
[
"setting_date"
];
}
return
$this
->
db_
->
field
(
"sum(a.attendance_num) as num,b.site_id"
)
->
alias
(
"a"
)
->
join
(
"a_store b"
,
"a.store_id = b.id"
,
"left"
)
->
where
(
$where_
)
->
group
(
"b.site_id"
)
->
select
();
}
public
function
sumOfficeAttendance
(
$params
){
$where_
=
[];
if
(
isset
(
$params
[
"is_del"
])){
$where_
[
"a.is_del"
]
=
$params
[
"is_del"
];
}
if
(
isset
(
$params
[
"setting_date"
])){
$where_
[
"a.setting_date"
]
=
$params
[
"setting_date"
];
}
if
(
isset
(
$params
[
"office_id"
])){
$where_
[
"b.office_id"
]
=
$params
[
"office_id"
];
}
return
$this
->
db_
->
field
(
"sum(a.attendance_num) as num"
)
->
alias
(
"a"
)
->
join
(
"a_store b"
,
"a.store_id = b.id"
,
"left"
)
->
where
(
$where_
)
->
select
();
}
}
}
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