Commit 8fff1e57 authored by clone's avatar clone

1

parent 6629e354
......@@ -283,6 +283,7 @@ class StoreFeeService
foreach ($storeSettingInfo as $key => $item) {
$applyForFeeArr = $this->getApplyForFee($item["store_id"], $setting_date);
$site_id = $applyForFeeArr[0]["site_id"];
$store_id = $item["store_id"];
$districtNum = $districtAttendanceNum[$site_id]["num"];//区域考勤人数
$attendance_num = $item["attendance_num"];//门店参与考勤人数
$officeAttendanceNum = $this->sumAttendanceNum($item["store_id"], 3, $setting_date);//办公室参与考勤人数
......@@ -308,7 +309,7 @@ class StoreFeeService
continue;
}
array_push($insertArr, $this->storeCostExtBin(
$cost_id, $type, $fee_item, $apply_for_id, $apply_for_time,
$cost_id, $store_id, $type, $fee_item, $apply_for_id, $apply_for_time,
$total_fee, $attendance_num, $officeAttendanceNum, $districtNum, $companyAttendanceNum,
$assume_fee, $purpose
));
......@@ -319,7 +320,7 @@ class StoreFeeService
$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"],
array_push($insertArr, $this->storeCostExtBin($cost_id, $store_id, 1, 100, 0, $item["create_time"],
$rent["rent"], $attendance_num, $officeAttendanceNum, $districtNum, $companyAttendanceNum,
ceil($attendance_num * 100 / $officeAttendanceNum) * $rent["rent"] * 0.01, ""
));
......@@ -333,11 +334,11 @@ class StoreFeeService
}
$assume_fee1 = ceil($attendance_discount / ($companyAttendanceNum - $discountsNum) * $tree[0]["fixed_fee"] * 100) * 0.01;
$assume_fee2 = ceil($attendance_discount / ($companyAttendanceNum - $discountsNum) * $tree[0]["apply_for_fee"] * 100) * 0.01;
array_push($insertArr, $this->storeCostExtBin($cost_id, 2, 201, 0, $tree[0]["create_time"],
array_push($insertArr, $this->storeCostExtBin($cost_id, $store_id, 2, 201, 0, $tree[0]["create_time"],
$tree[0]["fixed_fee"], $attendance_discount, $officeAttendanceNum, $districtNum, $companyAttendanceNum - $discountsNum,
$assume_fee1, ""
));
array_push($insertArr, $this->storeCostExtBin($cost_id, 2, 202, 0, $tree[0]["create_time"],
array_push($insertArr, $this->storeCostExtBin($cost_id, $store_id, 2, 202, 0, $tree[0]["create_time"],
$tree[0]["apply_for_fee"], $attendance_discount, $officeAttendanceNum, $districtNum, $companyAttendanceNum - $discountsNum,
$assume_fee2, ""
));
......@@ -382,22 +383,22 @@ class StoreFeeService
}
//同联发展基金
array_push($insertArr, $this->storeCostExtBin($cost_id, 4, 401, 0, $tree[4]["create_time"],
array_push($insertArr, $this->storeCostExtBin($cost_id, $store_id, 4, 401, 0, $tree[4]["create_time"],
0, $attendance_num, $officeAttendanceNum, $districtNum, $companyAttendanceNum,
$attendance_num * $tree[4]["fixed_fee"], ""
));
//社保报销费用
array_push($insertArr, $this->storeCostExtBin($cost_id, 5, 502, 0, $item["create_time"],
array_push($insertArr, $this->storeCostExtBin($cost_id, $store_id, 5, 502, 0, $item["create_time"],
$item["social_security_fee"], $attendance_num, $officeAttendanceNum, $districtNum, $companyAttendanceNum,
$item["social_security_fee"], ""
));
//总经理基薪
array_push($insertArr, $this->storeCostExtBin($cost_id, 5, 503, 0, $tree[6]["create_time"],
array_push($insertArr, $this->storeCostExtBin($cost_id, $store_id, 5, 503, 0, $tree[6]["create_time"],
$tree[6]["fixed_fee"], $attendance_num, $officeAttendanceNum, $districtNum, $companyAttendanceNum,
$tree[6]["fixed_fee"], ""
));
//手续费
array_push($insertArr, $this->storeCostExtBin($cost_id, 5, 509, 0, $item["create_time"],
array_push($insertArr, $this->storeCostExtBin($cost_id, $store_id, 5, 509, 0, $item["create_time"],
$item["transfer_charge"], $attendance_num, $officeAttendanceNum, $districtNum, $companyAttendanceNum,
$item["transfer_charge"], ""
));
......@@ -451,11 +452,12 @@ class StoreFeeService
return 0;
}
private function storeCostExtBin($cost_id, $type, $fee_item, $apply_for_id, $apply_for_time, $total_fee, $store_attendance_num,
private function storeCostExtBin($cost_id, $store_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["store_id"] = $store_id;
$arr["type"] = $type;
$arr["fee_item"] = $fee_item;
$arr["apply_for_id"] = $apply_for_id;
......@@ -542,4 +544,80 @@ class StoreFeeService
return $arr;
}
/**
* @param $setting_date
* @param $store_id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getStoreFeeDetail($setting_date, $store_id)
{
$storeCostModel = new FStoreCost();
$storeCostInfo = $storeCostModel->findByOne("id", ["setting_date" => $setting_date, "status" => 0]);
if (!$storeCostInfo) {
return false;
}
$field = "id,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,create_time,update_time";
$storeCostExtModel = new FStoreCostExt();
$params["store_id"] = $store_id;
$params["cost_id"] = $storeCostInfo["id"];
$params["is_del"] = 0;
$storeCostExtInfo = $storeCostExtModel->getStoreCostFeeList($field, $params);
if (!$storeCostExtInfo) {
return false;
}
$tree = [];
foreach ($storeCostExtInfo as $key => $item) {
$tree[$item["type"]][] = $item;
}
$result["store_list"]["info"] = $tree[1];
$result["store_list"]["total"] = $this->sumAssumeFee($tree[1]);
$result["company_list"]["info"] = $tree[2];
$result["company_list"]["total"] = $this->sumAssumeFee($tree[2]);
$result["district_list"]["info"] = $tree[3];
$result["district_list"]["total"] = $this->sumAssumeFee($tree[3]);
$result["development_fund_list"]["info"] = $tree[4];
$result["development_fund_list"]["total"] = $this->sumAssumeFee($tree[4]);
$result["store_alone_list"]["info"] = $tree[5];
$result["store_alone_list"]["total"] = $this->sumAssumeFee($tree[5]);
$storeDataModel = new FStoreData();
$storeDataInfo = $storeDataModel->findByOne("id,store_id,setting_date,official_receipts,last_official_receipts,
deduct", ["store_id" => $store_id]);
if (!$storeDataInfo) {
return false;
}
$result["total_cost"] = $this->sumAssumeFee($storeCostInfo);
$result["official_receipts"] = $storeDataInfo["official_receipts"];
$result["last_official_receipts"] = $storeDataInfo["last_official_receipts"];
$result["deduct"] = $storeDataInfo["deduct"];
$result["profit"] = $result["official_receipts"] - $result["total_cost"] - $result["last_official_receipts"];
return $result;
}
/**
* @param $result
* @return float
*/
private function sumAssumeFee($result)
{
$total = 0;
foreach ($result as $i => $j) {
$total += $j["assume_fee"];
}
return round($total * 100) * 0.01;
}
}
\ No newline at end of file
......@@ -40,7 +40,7 @@ class StoreFee extends Basic
public function creationStoreFee()
{
$params = $this->params;
/* $params = array(
/* $params = array(
"setting_date" => "2019-06-01",
"agent_id" => 1,
);*/
......@@ -67,6 +67,36 @@ class StoreFee extends Basic
}else{
return $this->response("200", "success");
}
}
/**
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getStoreFeeDetail(){
$params = $this->params;
/* $params = array(
"setting_date" => "2019-06-01",
"store_id" => 49,
);*/
if (!$params["setting_date"] || !$params["store_id"]) {
return $this->response("101", "请求参数错误 ");
}
$setting_date = $params["setting_date"];
$store_id = $params["store_id"];
$result = $this->service_->getStoreFeeDetail($setting_date,$store_id);
if($result){
return $this->response("200","success",$result);
}else{
return $this->response("101","暂未生成 $setting_date 数据");
}
}
/**
......
......@@ -143,4 +143,20 @@ class FStoreCostExt extends BaseModel
->select();
return $result;
}
/**
* @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 getStoreCostFeeList($field,$params){
return $this->db_
->field($field)
->where($params)
->select();
}
}
......@@ -551,6 +551,7 @@ Route::group('index', [
'addFeeImage' => ['index/StoreFee/addFeeImage', ['method' => 'POST']],//新增报销申请图片
'getStoreOffice' => ['index/Store/getStoreOffice', ['method' => 'GET']],//获取费用承担办公室
'creationStoreFee' => [ 'index/StoreFee/creationStoreFee', [ 'method' => 'POST|GET' ] ],
'getStoreFeeDetail' => [ 'index/StoreFee/getStoreFeeDetail', [ 'method' => 'POST|GET' ] ],
'getStoreCostParameterList' => [ 'index/CostParameter/getStoreCostParameterList', [ 'method' => 'POST|GET' ] ],
'editCostParameter' => [ 'index/CostParameter/editCostParameter', [ 'method' => 'POST|GET' ] ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment