Commit 7d0651fd authored by clone's avatar clone

1

parent 7bcdd772
......@@ -7,6 +7,7 @@ use app\model\FApplyForFee;
use app\model\FCompanyData;
use app\model\FImg;
use app\model\FOffice;
use app\model\FSettingLog;
use app\model\FStoreCost;
use app\model\FStoreCostExt;
use app\model\FStoreData;
......@@ -50,7 +51,7 @@ class StoreFeeService
$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,
$bank, $card_no, $count_time, $office_id,0);
$bank, $card_no, $count_time, $office_id, 0);
if ($id) {
$this->applyForFeeModel->updateData($arr, ['id' => $id]);
$feeId = $id;
......@@ -234,6 +235,21 @@ class StoreFeeService
return $result;
}
/**
* @param $setting_date
* @return bool
*/
public function verifyCheck($setting_date)
{
$settingLogModel = new FSettingLog();
$list = $settingLogModel->verifyCheck("id", ["setting_date" => $setting_date]);
if(count($list) == 5){
return true;
}else{
return false;
}
}
/**
* @param $setting_date
* @param $agent_id
......@@ -249,7 +265,7 @@ class StoreFeeService
$storeCostModel->updateCost(["setting_date" => $setting_date], ["status" => 1]);// 修改掉之前的全部失效
$id = $storeCostModel->addCost(
$this->storeCostBin($setting_date, $agent_id, $agent_name)
);
);//保存主表数据
if ($id > 0) {
return $this->creationStoreFeeDetail($id, $setting_date);
}
......@@ -278,10 +294,11 @@ class StoreFeeService
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);
$is_ok = 0;
foreach ($storeSettingInfo as $key => $item) {
$applyForFeeArr = $this->getApplyForFee($item["store_id"], $setting_date);
......@@ -318,7 +335,7 @@ class StoreFeeService
));
}
}
//todo 处理 房租租金 上海固定成本分部固定成本 发展基金社保报销 总经理薪资 手续费
// 处理 房租租金 上海固定成本分部固定成本 发展基金社保报销 总经理薪资 手续费
//门店租金
$storeModel = new AStore();
$rent = $storeModel->getStoreCost("b.id,b.rent", ["a.id" => $item["store_id"]]);
......@@ -488,14 +505,14 @@ class StoreFeeService
*/
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,
$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.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;
$params["a.status"] = 4;*/
$condition = "b.id =".$store_id." and a.count_time='".$setting_date. "' and a.is_del = 0 and a.status = 4";
/* $params["b.id"] = $store_id;
$params["a.count_time"] = $setting_date;
$params["a.is_del"] = 0;
$params["a.status"] = 4;*/
$condition = "b.id =" . $store_id . " and a.count_time='" . $setting_date . "' and a.is_del = 0 and a.status = 4";
return $applyForFeeModel->getApplyForFeeList($field, $condition);
}
......@@ -561,8 +578,8 @@ class StoreFeeService
public function getStoreFeeDetail($setting_date, $store_id)
{
$storeModel = new AStore();
$storeInfo = $storeModel->getStore(["id"=>$store_id],"id,site_id");
if(!$storeInfo){
$storeInfo = $storeModel->getStore(["id" => $store_id], "id,site_id");
if (!$storeInfo) {
return false;
}
$storeCostModel = new FStoreCost();
......
......@@ -50,7 +50,7 @@ class StoreFee extends Basic
$setting_date = $params["setting_date"];
$agent_id = $params["agent_id"];
//todo 验证用户数据
// 验证用户数据
$cache = new RedisCacheService();
$agent_info = $cache->getRedisCache(2, $agent_id);
if(!$agent_info){
......@@ -58,9 +58,12 @@ class StoreFee extends Basic
}
$agent_name = $agent_info["name"];
//todo 1.判断是否都审核过,
//todo 2.计算门店成本 3.总部成本,4.分部成本,5.同联发展基金 6门店单独成本
// 1.判断是否都审核过,
$is_check = $this->service_->verifyCheck($setting_date);
if(!$is_check){
return $this->response("101", "请先审核所有设置数据然后再提交一键生成! ");
}
// 2.计算门店成本 3.总部成本,4.分部成本,5.同联发展基金 6门店单独成本
$msg = $this->service_->calculateStoreFee($setting_date, $agent_id,$agent_name);
if($msg != 1){
return $this->response("101", $msg);
......
......@@ -55,4 +55,14 @@ class FSettingLog extends BaseModel
->select();
return $result;
}
public function verifyCheck($field, $params){
$params['is_del'] = 0;
$result = $this->db_
->field($field)
->where($params)
->group( "type")
->select();
return $result;
}
}
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