"徐从伟", //姓名
"wages" => 6000, //工资 //试用期90%,正式工资5500
"late_num" => 0, //迟到次数
"card_num" => 0, //缺卡次数
"leave" => 1, //请假天数
"commission" => 0, //提成
"haveSocial" => 1, //是否有社保1:有;0:无,
],
[
"name" => "李禹江", //姓名
"wages" => 3000, //工资,无社保
"late_num" => 0, //迟到次数
"card_num" => 0, //缺卡次数
"leave" => 6.5, //请假天数
"commission" => 0, //提成
"haveSocial" => 0, //是否有社保1:有;0:无
"collection" => 900, //收款金额
],
[
"name" => "尹财波", //姓名
"wages" => 7500, //工资,无社保
"late_num" => 0, //迟到次数
"card_num" => 0, //缺卡次数
"leave" => 0, //请假天数
"commission" => 0, //提成
"haveSocial" => 0, //是否有社保1:有;0:无
],
[
"name" => "郑继领", //姓名
"wages" => 3000, //工资,无社保
"late_num" => 0, //迟到次数
"card_num" => 0, //缺卡次数
"leave" => 0, //请假天数
"commission" => 0, //提成
"haveSocial" => 0, //是否有社保1:有;0:无
"collection" => 31268, //收款金额
],
];
$total = 0; //所有金额
$socialNumber = 0; //社保人数
$str = $month . "工资明细:
";
foreach ($staffs as $s) {
$haveCommission = true; //是否计算提成
$perTotal = $s["wages"]; //个人合计
$str .= $s["name"] . ",{$month} 工资明细:
";
$str .= "基本工资:" . $s["wages"] . "
";
$num = $s["late_num"] + $s["card_num"] - 3;
$dayWage = $s["wages"] / 22;
$hourlyWage = $dayWage / 8;
if ($num > 0) {
$deduction = round($hourlyWage * $num, 2);
} else {
$deduction = 0;
}
//$wagesStr = '应发工资(' . $s['wages'];
$wagesStr = "应发工资(" . $perTotal;
$str .= "迟到次数:" .
$s["late_num"] .
"
缺卡次数:" .
$s["card_num"] .
"
";
$str .= "请假天数:" . $s["leave"] . "
";
if ($s["leave"] > 0) {
$deduction += round($dayWage * $s["leave"], 2);
}
if ($deduction > 0) {
$str .= "扣款:" . $deduction . "元
";
$wagesStr .= " - " . $deduction;
$perTotal = $perTotal - $deduction;
}
if ($s["haveSocial"]) {
$str .= "
";
$str .= "社保扣款:" . $social . "元
";
$str .= "
";
$wagesStr .= " - " . $social;
$perTotal = $perTotal - $social;
$socialNumber++;
}
//销售收款计算提成
if (isset($s["collection"]) && $s["collection"] > 0) {
$commission = 0;
if ($s["collection"] > 80000) {
$commission = $s["collection"] * 0.15;
} elseif ($s["collection"] > 60000) {
$commission = $s["collection"] * 0.14;
} elseif ($s["collection"] > 40000) {
$commission = $s["collection"] * 0.12;
} elseif ($s["collection"] > 20000) {
$commission = $s["collection"] * 0.1;
} else {
$commission = $s["collection"] * 0.08;
}
if ($commission > 0) {
$s["commission"] = $commission;
}
}
if ($s["commission"] > 0) {
$str .= "收款:" . $s["collection"] . "
";
$str .= "提成:" . $s["commission"] . "
";
if ($haveCommission) {
$wagesStr .= " + " . $s["commission"];
$perTotal = $perTotal + $s["commission"];
} else {
$str .= "提成不计算!按保底90%计算工资
";
}
$str .= "
";
}
$perTotal = round($perTotal, 2);
$wagesStr .= ") = " . $perTotal . "元";
$str .= $wagesStr . "
";
$str .= "
";
$total += $perTotal;
}
$socialTotal = ($socialNumber + 2) * 1505.63;
$str .= "社保总金额:" . $socialTotal . " 元
";
$str .= "工资总金额:" . $total . " 元
";
$str .= "总金额:" . $total + $socialTotal . " 元";
return $str;
}
}