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
aeda6327
Commit
aeda6327
authored
Jul 24, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
70f4307d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
37 deletions
+164
-37
StoreFeeService.php
application/api_broker/service/StoreFeeService.php
+128
-30
StoreFee.php
application/index/controller/StoreFee.php
+6
-1
FApplyForFee.php
application/model/FApplyForFee.php
+1
-1
FOffice.php
application/model/FOffice.php
+17
-5
FStoreCostExt.php
application/model/FStoreCostExt.php
+12
-0
No files found.
application/api_broker/service/StoreFeeService.php
View file @
aeda6327
...
...
@@ -2,10 +2,13 @@
namespace
app\api_broker\service
;
use
app\model\AStore
;
use
app\model\FApplyForFee
;
use
app\model\FCompanyData
;
use
app\model\FImg
;
use
app\model\FOffice
;
use
app\model\FStoreCost
;
use
app\model\FStoreCostExt
;
use
app\model\FStoreData
;
/**
...
...
@@ -46,10 +49,10 @@ class StoreFeeService
public
function
addApplyFor
(
$type
,
$fee_item
,
$total_fee
,
$agent_id
,
$store_id
,
$purpose
,
$site_id
,
$card_name
,
$bank
,
$card_no
,
$count_time
,
$img_arr
,
$id
=
0
,
$office_id
=
0
)
{
$arr
=
$this
->
applyForFeeBin
(
$id
,
$type
,
$fee_item
,
$total_fee
,
$agent_id
,
$store_id
,
$purpose
,
$site_id
,
$card_name
,
$arr
=
$this
->
applyForFeeBin
(
$id
,
$type
,
$fee_item
,
$total_fee
,
$agent_id
,
$store_id
,
$purpose
,
$site_id
,
$card_name
,
$bank
,
$card_no
,
$count_time
,
$office_id
);
if
(
$id
)
{
$this
->
applyForFeeModel
->
updateData
(
$arr
,
[
'id'
=>
$id
]);
$this
->
applyForFeeModel
->
updateData
(
$arr
,
[
'id'
=>
$id
]);
$feeId
=
$id
;
}
else
{
$feeId
=
$this
->
applyForFeeModel
->
saveData
(
$arr
);
...
...
@@ -205,7 +208,7 @@ class StoreFeeService
*/
public
function
delImg
(
$id_string
)
{
$image_array
=
explode
(
','
,
$id_string
);
$image_array
=
explode
(
','
,
$id_string
);
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
''
;
if
(
!
is_array
(
$image_array
)
&&
!
is_numeric
(
$id_string
))
{
...
...
@@ -237,7 +240,7 @@ class StoreFeeService
$this
->
storeCostBin
(
$setting_date
,
$agent_id
,
$agent_name
)
);
if
(
$id
>
0
)
{
$this
->
creationStoreFeeDetail
(
$id
,
$setting_date
);
return
$this
->
creationStoreFeeDetail
(
$id
,
$setting_date
);
}
return
false
;
}
...
...
@@ -252,54 +255,144 @@ class StoreFeeService
if
(
!
$companyDataInfo
)
{
return
"当月公司数据未设置"
;
}
$tree
=
[];
foreach
(
$companyDataInfo
as
$i
=>
$j
)
{
$tree
[
$j
[
"type"
]][]
=
$j
;
}
//todo 计算公司总考勤数 和分部考勤数
$companyAttendanceNum
=
$this
->
sumAttendanceNum
(
0
,
1
,
$setting_date
);
$districtAttendanceNum
=
$this
->
sumAttendanceNum
(
0
,
2
,
$setting_date
);
$discountsNum
=
$this
->
sumAttendanceNum
(
0
,
4
,
$setting_date
);
foreach
(
$storeSettingInfo
as
$key
=>
$item
)
{
$applyForFeeArr
=
$this
->
getApplyForFee
(
$item
[
"store_id"
],
$setting_date
);
//门店
$insertArr
=
[];
$applyForFeeArr
=
$this
->
getApplyForFee
(
$item
[
"store_id"
],
$setting_date
);
$site_id
=
$applyForFeeArr
[
0
][
"site_id"
];
$attendance_num
=
$item
[
"attendance_num"
];
//门店参与考勤人数
$officeAttendanceNum
=
$this
->
sumAttendanceNum
(
$item
[
"store_id"
],
3
,
$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"
];
$type
=
$value
[
"type"
];
$fee_item
=
$value
[
"fee_item"
];
$apply_for_id
=
$value
[
"id"
];
$apply_for_time
=
$value
[
"create_time"
];
$total_fee
=
$value
[
"total_fee"
];
$purpose
=
$value
[
"purpose"
];
$assume_fee
=
0
;
switch
(
$value
[
"type"
])
{
case
1
://
办公室成本
$assume_fee
=
ceil
(
$attendance_num
/
$officeAttendanceNum
*
100
)
*
$total_fee
*
0.01
;
break
;
case
2
:
/*
case 2:
//公司总考勤减去所有计算折扣的门店人数
if
(
$item
[
"is_discounts"
]
==
1
){
$attendance_num
=
$value
[
"attendance_num"
]
/
2
;
$a
ssume_fee
=
ceil
(
$attendance_num
/
$officeAttendanceNum
-
12312
*
100
)
*
$total_fee
*
0.01
;
$companyAttendanceNum = $companyAttendanceNum - $discountsNum;
if ($item["is_discounts"] == 1) {
$a
ttendance_num = $value["attendance_num"] / $tree[0]["discounts"]
* 0.01;
}
$assume_fee = ceil($attendance_num * 100 / $companyAttendanceNum) * $total_fee * 0.01;
break;
case 3:
break
;
case
4
:
$assume_fee = ceil($attendance_num * 100 / $districtAttendanceNum) * $total_fee * 0.01;
break;
*/
case
5
://
门店独有成本
$assume_fee
=
$total_fee
;
break
;
default
:
continue
;
}
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
$cost_id
,
$type
,
$fee_item
,
$apply_for_id
,
$apply_for_time
,
$total_fee
,
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
$assume_fee
,
$purpose
));
}
//todo 处理 房租租金 上海固定成本分部固定成本 发展基金社保报销 总经理薪资 手续费
//门店租金
$storeModel
=
new
AStore
();
$rent
=
$storeModel
->
getStoreCost
(
"b.id,b.rent"
,
[
"a.id"
=>
$item
[
"store_id"
]]);
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
1
,
100
,
0
,
$item
[
"create_time"
],
$rent
[
"rent"
],
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
ceil
(
$attendance_num
*
100
/
$officeAttendanceNum
)
*
$rent
[
"rent"
]
*
0.01
,
""
));
//上海总部固定成本 门店是上海的只承担总部成本,否则承担总部和分部成本
//上海
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
2
,
201
,
0
,
$tree
[
0
][
"create_time"
],
$tree
[
0
][
"fixed_fee"
],
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
-
$discountsNum
,
ceil
(
$attendance_num
*
$tree
[
0
][
"discounts"
]
/
$officeAttendanceNum
-
$discountsNum
)
*
$tree
[
0
][
"fixed_fee"
]
*
0.01
,
""
));
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
2
,
202
,
0
,
$tree
[
0
][
"create_time"
],
$tree
[
0
][
"apply_for_fee"
],
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
-
$discountsNum
,
ceil
(
$attendance_num
*
$tree
[
0
][
"discounts"
]
/
$officeAttendanceNum
-
$discountsNum
)
*
$tree
[
0
][
"apply_for_fee"
]
*
0.01
,
""
));
$create_time
=
""
;
$rent_fixed
=
0
;
switch
(
$site_id
)
{
case
10002
:
$create_time
=
$tree
[
1
][
"create_time"
];
$rent_fixed
=
$tree
[
1
][
"fixed_fee"
];
$apply_for_fee
=
$tree
[
1
][
"apply_for_fee"
];
break
;
case
10003
:
$create_time
=
$tree
[
2
][
"create_time"
];
$rent_fixed
=
$tree
[
2
][
"fixed_fee"
];
$apply_for_fee
=
$tree
[
2
][
"apply_for_fee"
];
break
;
case
10004
:
$create_time
=
$tree
[
3
][
"create_time"
];
$rent_fixed
=
$tree
[
3
][
"fixed_fee"
];
$apply_for_fee
=
$tree
[
3
][
"apply_for_fee"
];
break
;
case
10005
:
$create_time
=
$tree
[
4
][
"create_time"
];
$rent_fixed
=
$tree
[
4
][
"fixed_fee"
];
$apply_for_fee
=
$tree
[
4
][
"apply_for_fee"
];
break
;
}
//分部
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
3
,
301
,
0
,
$create_time
,
$rent_fixed
,
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
ceil
(
$attendance_num
*
100
/
$officeAttendanceNum
)
*
$rent_fixed
*
0.01
,
""
));
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
3
,
302
,
0
,
$create_time
,
$apply_for_fee
,
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
ceil
(
$attendance_num
*
100
/
$officeAttendanceNum
)
*
$apply_for_fee
*
0.01
,
""
));
//同联发展基金
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
4
,
401
,
0
,
$tree
[
4
][
"create_time"
],
$tree
[
0
][
"fixed_fee"
],
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
$attendance_num
*
$tree
[
4
][
"fixed_fee"
],
""
));
//社保报销费用
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
5
,
502
,
0
,
$item
[
"create_time"
],
$item
[
"social_security_fee"
],
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
$item
[
"social_security_fee"
],
""
));
//总经理基薪
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
5
,
503
,
0
,
$tree
[
6
][
"create_time"
],
$tree
[
6
][
"fixed_fee"
],
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
$tree
[
6
][
"fixed_fee"
],
""
));
//手续费
array_push
(
$insertArr
,
$this
->
storeCostExtBin
(
$cost_id
,
5
,
509
,
0
,
$item
[
"create_time"
],
$item
[
"transfer_charge"
],
$attendance_num
,
$officeAttendanceNum
,
$districtAttendanceNum
,
$companyAttendanceNum
,
$item
[
"transfer_charge"
],
""
));
}
//insert
$storeCostExtModel
=
new
FStoreCostExt
();
$is_ok
=
$storeCostExtModel
->
addCostExt
(
$insertArr
);
if
(
$is_ok
){
return
1
;
}
else
{
return
"数据保存异常"
;
}
}
}
/**
* @param $id
* @param $type
...
...
@@ -317,8 +410,13 @@ class StoreFeeService
case
2
://
分部
return
$storeDataModel
->
sumDistrictAttendance
(
$params
);
case
3
://
办公室
$params
[
"office_id"
]
=
$id
;
$storeModel
=
new
AStore
();
$storeInfo
=
$storeModel
->
getStore
([
"id"
=>
$id
],
"office_id"
);
$params
[
"office_id"
]
=
$storeInfo
[
0
][
"office_id"
];
return
$storeDataModel
->
sumOfficeAttendance
(
$params
);
case
4
://
参与折扣的人数
$params
[
"is_discounts"
]
=
1
;
return
$storeDataModel
->
sumCompanyAttendance
(
$params
);
}
return
0
;
}
...
...
@@ -354,7 +452,7 @@ class StoreFeeService
{
$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"
;
a.status,a.count_time,a.site_id,a.create_time,b.id as old_store_id,b.office_id as old_office_id
,b.site_id
"
;
$params
[
"b.id"
]
=
$store_id
;
$params
[
"a.count_time"
]
=
$setting_date
;
$params
[
"a.is_del"
]
=
0
;
...
...
@@ -372,7 +470,7 @@ class StoreFeeService
private
function
getStoreData
(
$setting_date
)
{
$storeDataModel
=
new
FStoreData
();
$field
=
"id,setting_date,type,fixed_fee,apply_for_fee,discounts"
;
$field
=
"id,setting_date,type,fixed_fee,apply_for_fee,discounts
,create_time
"
;
$params
[
"is_del"
]
=
0
;
$params
[
"setting_date"
]
=
$setting_date
;
return
$storeDataModel
->
selectStoreFee
(
$field
,
$params
);
...
...
@@ -389,7 +487,7 @@ class StoreFeeService
{
$companyData
=
new
FCompanyData
();
$field
=
"id,store_id,setting_date,is_discounts,social_security_fee,attendance_num,official_receipts,
last_official_receipts,deduct,transfer_charge"
;
last_official_receipts,deduct,transfer_charge
,create_time
"
;
$params
[
"is_del"
]
=
0
;
$params
[
"setting_date"
]
=
$setting_date
;
return
$companyData
->
selectCompanyData
(
$field
,
$params
);
...
...
application/index/controller/StoreFee.php
View file @
aeda6327
...
...
@@ -56,7 +56,12 @@ class StoreFee extends Basic
//todo 1.判断是否都审核过,
//todo 2.计算门店成本 3.总部成本,4.分部成本,5.同联发展基金 6门店单独成本
$this
->
service_
->
calculateStoreFee
(
$setting_date
,
$agent_id
,
$agent_name
);
$msg
=
$this
->
service_
->
calculateStoreFee
(
$setting_date
,
$agent_id
,
$agent_name
);
if
(
$msg
!=
1
){
return
$this
->
response
(
"101"
,
$msg
);
}
else
{
return
$this
->
response
(
"200"
,
"success"
);
}
}
/**
...
...
application/model/FApplyForFee.php
View file @
aeda6327
...
...
@@ -90,7 +90,7 @@ class FApplyForFee extends BaseModel
return
$this
->
db_
->
field
(
$field
)
->
alias
(
"a"
)
->
join
(
"
f_apply_for_fe
e b"
,
"a.store_id = b.id"
,
"left"
)
->
join
(
"
a_stor
e b"
,
"a.store_id = b.id"
,
"left"
)
->
where
(
$params
)
->
select
();
}
...
...
application/model/FOffice.php
View file @
aeda6327
...
...
@@ -35,6 +35,9 @@ class FOffice extends BaseModel
* @param $field
* @param $params
* @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
)
{
$params
[
"is_del"
]
=
0
;
...
...
@@ -46,12 +49,15 @@ class FOffice extends BaseModel
return
$result
;
}
/**
* 查询数据
/**查询数据
* @param $field
* @param $params
* @param $pageNo
* @param $pageSize
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getOffice
(
$field
,
$params
,
$pageNo
,
$pageSize
)
{
...
...
@@ -65,6 +71,11 @@ class FOffice extends BaseModel
return
$result
;
}
/**
* @param $field
* @param $params
* @return int|string
*/
public
function
getOfficeTotal
(
$field
,
$params
)
{
$params
[
'is_del'
]
=
0
;
...
...
@@ -75,10 +86,11 @@ class FOffice extends BaseModel
return
$result
;
}
/**
* 更新数据
/**更新数据
* @param $params
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public
function
updateOffice
(
$params
)
{
...
...
application/model/FStoreCostExt.php
View file @
aeda6327
...
...
@@ -16,6 +16,18 @@ class FStoreCostExt extends BaseModel
$this
->
db_
=
Db
::
name
(
$this
->
table
);
}
public
function
addCostExt
(
$params
)
{
Db
::
startTrans
();
try
{
$this
->
db_
->
insertAll
(
$params
);
Db
::
commit
();
return
1
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
0
;
}
}
/**
* 查询数据
...
...
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