...
|
...
|
@@ -26,6 +26,8 @@ class AfterToBefore extends Api |
|
|
*
|
|
|
* @ApiParams (name="salary_hand_average", type="inter", required=true, description="税后每月工资")
|
|
|
* @ApiParams (name="add_money", type="inter", required=false, description="每月专项附加金额")
|
|
|
* @ApiParams (name="social_base", type="inter", required=false, description="社保汇缴基数")
|
|
|
* @ApiParams (name="housing_fund_base", type="inter", required=false, description="公积金汇缴基数")
|
|
|
* @ApiParams (name="housing_fund_rate", type="inter", required=false, description="公积金汇缴比例")
|
|
|
*
|
|
|
* @ApiReturn({
|
...
|
...
|
@@ -259,6 +261,8 @@ class AfterToBefore extends Api |
|
|
$param = $this->request->param(); //返回给前端
|
|
|
$salary_hand_average = $this->request->param('salary_hand_average',0);
|
|
|
$add_money = $this->request->param('add_money',0);
|
|
|
$social_base = $this->request->param('social_base');
|
|
|
$housing_fund_base = $this->request->param('housing_fund_base');
|
|
|
$housing_fund_rate = $this->request->param('housing_fund_rate');
|
|
|
empty($salary_hand_average) && $this->error('请输入税后平均每月工资');
|
|
|
if(empty($add_money)){
|
...
|
...
|
@@ -267,9 +271,21 @@ class AfterToBefore extends Api |
|
|
// 社保基数
|
|
|
$social_top = config('site.social_top_after'); //社保封顶金额
|
|
|
$social_bottom = config('site.social_bottom_after'); //社保保底金额
|
|
|
if(!empty($social_base)){
|
|
|
$social_base > $social_top && $this->error('社保汇缴基数不能大于'.$social_top);
|
|
|
$social_base < $social_bottom && $this->error('社保汇缴基数不能小于'.$social_bottom);
|
|
|
}else{
|
|
|
$social_base = $salary_hand_average > $social_top ? $social_top : ($salary_hand_average < $social_bottom ? $social_bottom : $salary_hand_average);
|
|
|
}
|
|
|
// 公积金基数
|
|
|
$housing_fund_top = config('site.housing_fund_top_after'); //公积金封顶金额
|
|
|
$housing_fund_bottom = config('site.housing_fund_bottom_after'); //公积金保底金额
|
|
|
if(!empty($housing_fund_base)){
|
|
|
$housing_fund_base > $housing_fund_top && $this->error('公积金汇缴基数不能大于'.$housing_fund_top);
|
|
|
$housing_fund_base < $housing_fund_bottom && $this->error('公积金汇缴基数不能小于'.$housing_fund_bottom);
|
|
|
}else{
|
|
|
$housing_fund_base = $salary_hand_average > $housing_fund_top ? $housing_fund_top : ($salary_hand_average < $housing_fund_bottom ? $housing_fund_bottom : $salary_hand_average);
|
|
|
}
|
|
|
// 公积金缴存比例5%-7%
|
|
|
$social_rate_user = Db::name('social_insurance_rate')->where('id',1)->find();
|
|
|
$social_rate_company = Db::name('social_insurance_rate')->where('id',2)->find();
|
...
|
...
|
@@ -279,10 +295,10 @@ class AfterToBefore extends Api |
|
|
}else{
|
|
|
$housing_fund_rate = config('site.housing_fund_rate');
|
|
|
}
|
|
|
// 每月个人承担的三险比例(其中养老8%,医疗2%,失业0.5%,三种保险总和为10.5%,上海地区个人承担的三种保险比例一致。)
|
|
|
$social_rate = ($social_rate_user['endowment']+$social_rate_user['medical']+$social_rate_user['unemployment']+$social_rate_user['birth']+$social_rate_user['industrial'])/100;
|
|
|
// 个人五险一金比例
|
|
|
$wuxianyijin_rate = ($social_rate_user['endowment']+$social_rate_user['medical']+$social_rate_user['unemployment']+$social_rate_user['birth']+$housing_fund_rate)/100;
|
|
|
$fee_top = $social_top*$wuxianyijin_rate; //三金封顶费用
|
|
|
$fee_bottom = $social_bottom*$wuxianyijin_rate; //三金保底费用
|
|
|
$tax_rate_new = db('tax_rate_new')->order('level desc')->select();
|
|
|
// 月份
|
|
|
$month = 12;
|
...
|
...
|
@@ -307,17 +323,10 @@ class AfterToBefore extends Api |
|
|
}
|
|
|
// 累计个人所得税
|
|
|
$person_fee_total = $suode == 0 ? 0 : $suode+$dec_fee_total-$salary_hand;
|
|
|
// 每月个人承担的公积金
|
|
|
$housing_fund = $housing_fund_base * $housing_fund_rate / 100;
|
|
|
// 个人三险一金部分
|
|
|
$san_gong_money_total = 0;
|
|
|
if(($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)/$month>=$social_top){
|
|
|
$san_gong_money_total = $fee_top*$month;
|
|
|
}else{
|
|
|
if(($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)/$month>=$fee_bottom){
|
|
|
$san_gong_money_total = ($salary_hand+$person_fee_total)/(1-$wuxianyijin_rate)*$wuxianyijin_rate;
|
|
|
}else{
|
|
|
$san_gong_money_total = $fee_bottom*$month;
|
|
|
}
|
|
|
}
|
|
|
$san_gong_money_total = ($social_base*$social_rate+$housing_fund)*$month;
|
|
|
// 累计工资总额
|
|
|
$salary_total = $salary_hand + $person_fee_total + $san_gong_money_total;
|
|
|
// 平均个税金额
|
...
|
...
|
@@ -328,27 +337,27 @@ class AfterToBefore extends Api |
|
|
$social_user = [
|
|
|
'housing_fund' => [
|
|
|
'rate' => $housing_fund_rate,
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($housing_fund_rate/100)/$month,2)
|
|
|
'money' => round($housing_fund,2)
|
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_user['endowment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['endowment']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_user['endowment']/100,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_user['medical'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['medical']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_user['medical']/100,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_user['unemployment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['unemployment']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_user['unemployment']/100,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_user['birth'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['birth']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_user['birth']/100,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_user['industrial'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_user['industrial']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_user['industrial']/100,2)
|
|
|
],
|
|
|
];
|
|
|
// 五险一金汇缴明细-个人合计
|
...
|
...
|
@@ -361,23 +370,23 @@ class AfterToBefore extends Api |
|
|
],
|
|
|
'endowment' => [
|
|
|
'rate' => $social_rate_company['endowment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['endowment']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_company['endowment']/100,2)
|
|
|
],
|
|
|
'medical' => [
|
|
|
'rate' => $social_rate_company['medical'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['medical']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_company['medical']/100,2)
|
|
|
],
|
|
|
'unemployment' => [
|
|
|
'rate' => $social_rate_company['unemployment'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['unemployment']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_company['unemployment']/100,2)
|
|
|
],
|
|
|
'birth' => [
|
|
|
'rate' => $social_rate_company['birth'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['birth']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_company['birth']/100,2)
|
|
|
],
|
|
|
'industrial' => [
|
|
|
'rate' => $social_rate_company['industrial'],
|
|
|
'money' => round($san_gong_money_total/$wuxianyijin_rate*($social_rate_company['industrial']/100)/$month,2)
|
|
|
'money' => round($social_base * $social_rate_company['industrial']/100,2)
|
|
|
],
|
|
|
];
|
|
|
// 五险一金汇缴明细-单位合计
|
...
|
...
|
@@ -496,10 +505,6 @@ class AfterToBefore extends Api |
|
|
]
|
|
|
],$user_go['en']),
|
|
|
];
|
|
|
// 社保汇缴基数
|
|
|
$social_base = $salary_average > $social_top ? $social_top : ($salary_average < $social_bottom ? $social_bottom : $salary_average);
|
|
|
// 公积金汇缴基数
|
|
|
$housing_fund_base = $salary_average > $housing_fund_top ? $housing_fund_top : ($salary_average < $housing_fund_bottom ? $housing_fund_bottom : $salary_average);
|
|
|
$this->success('请求成功',compact('param','salary_average','social_user','social_user_money','social_company','social_company_money','person_fee_average','company_cost','user_go','company_go','social_base','housing_fund_base'));
|
|
|
|
|
|
}
|
...
|
...
|
|