123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- /**
- * @copyright Copyright (c) 2021 勾股工作室
- * @license https://opensource.org/licenses/Apache-2.0
- * @link https://www.gougucms.com
- */
- declare (strict_types=1);
- namespace app\mobile\controller;
- use app\admin\BaseController;
- use app\admin\model\Admin;
- use app\admin\model\CostProject as CostProjectModel;
- use app\admin\model\ProjectAudit as AuditModel;
- use think\App;
- use think\facade\Db;
- use think\facade\View;
- class Index_company extends BaseController
- {
- /**
- * 构造函数
- */
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->model = new CostProjectModel();
- $this->Adminmodel = new Admin();
- $this->Auditmodel = new AuditModel();
- $this->uid = get_login_admin('id');
- $this->unit = get_login_admin('unit_name');
- }
- /**
- * 公司首页
- */
- public function main_company()
- {
- $sent_review_amount = Db::name("cost_project")->where([
- ["review_unit", "=", get_login_admin("unit_name")],
- ['delete_time', '=', 0],
- ['project_status', '>', 3],
- ])->field("sent_review_amount,sent_review_cost,review_add_reduce_rate,authorize_amount,engineering_type1")->select();
- //engineering_type1=1是预算,2是结算
- $amount = [
- //送审总额
- 'sent_review_amount' => 0,
- //评审服务费
- 'sent_review_cost' => 0,
- //审定总额
- 'authorize_amount' => 0,
- //总审减率
- 'review_add_reduce_rate' => 0
- ];
- $sent_review_amount_tol = [
- "sent_review_amount_type1" => 0,
- "sent_review_amount_type2" => 0,
- "authorize_amount_type1" => 0,
- "authorize_amount_type2" => 0,
- "review_add_reduce_rate_type1" => 0,
- "review_add_reduce_rate_type2" => 0
- ];
- for ($i = 0; $i < count($sent_review_amount); $i++) {
- $a = $sent_review_amount[$i];
- if ($a['engineering_type1'] == 1) {
- if ($a["sent_review_amount"] && $a["authorize_amount"]) {
- //预算总额
- $sent_review_amount_tol["sent_review_amount_type1"] += $a["sent_review_amount"];
- //审定
- $sent_review_amount_tol["authorize_amount_type1"] += $a["authorize_amount"];
- }
- } elseif ($a['engineering_type1'] == 2) {
- if ($a["sent_review_amount"] && $a["authorize_amount"]) {
- //结算总额
- $sent_review_amount_tol["sent_review_amount_type2"] += $a["sent_review_amount"];
- //审定
- $sent_review_amount_tol["authorize_amount_type2"] += $a["authorize_amount"];
- }
- }
- }
- if ($sent_review_amount_tol["sent_review_amount_type1"] && $sent_review_amount_tol["authorize_amount_type1"]) {
- //预算核增减率
- $sent_review_amount_tol["review_add_reduce_rate_type1"] = (sprintf("%.4f", ($sent_review_amount_tol["authorize_amount_type1"] - $sent_review_amount_tol["sent_review_amount_type1"]) / $sent_review_amount_tol["sent_review_amount_type1"])) * 100;
- }
- if ($sent_review_amount_tol["sent_review_amount_type2"] && $sent_review_amount_tol["authorize_amount_type2"]) {
- //结算核增减率
- $sent_review_amount_tol["review_add_reduce_rate_type2"] = (sprintf("%.4f", ($sent_review_amount_tol["authorize_amount_type2"] - $sent_review_amount_tol["sent_review_amount_type2"]) / $sent_review_amount_tol["sent_review_amount_type2"])) * 100;
- }
- for ($i = 0; $i < count($sent_review_amount); $i++) {
- $a = $sent_review_amount[$i];
- if ($a['sent_review_amount'] && $a['sent_review_cost'] && $a['authorize_amount']) {
- $amount["sent_review_amount"] += $a['sent_review_amount'];
- $amount["sent_review_cost"] += $a['sent_review_cost'];
- $amount["authorize_amount"] += $a['authorize_amount'];
- }
- }
- if ($amount['sent_review_amount'] && $amount["authorize_amount"]) {
- $amount['review_add_reduce_rate'] = (sprintf("%.4f", ($amount["authorize_amount"] - $amount["sent_review_amount"]) / $amount["sent_review_amount"])) * 100;
- }
- //评审服务费,上半年服务费用,下半年服务费用 start
- $currentTime = time();
- $year = date('Y', $currentTime);
- // 计算上半年时间范围
- $firstHalfStart = strtotime($year . '-01-01');
- $firstHalfEnd = strtotime($year . '-06-30 23:59:59');
- // 计算下半年时间范围
- $secondHalfStart = strtotime($year . '-07-01');
- $secondHalfEnd = strtotime($year . '-12-31 23:59:59');
- $first_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 2], ["review_unit", "=", get_login_admin("unit_name")]
- ])->
- whereBetween('create_time', [$firstHalfStart, $firstHalfEnd])->field("sent_review_cost")->select()->toArray();
- $second_sent_review_cost = Db::name("cost_project")->where([
- ['project_status', '>', 2], ["review_unit", "=", get_login_admin("unit_name")]
- ])->
- whereBetween('create_time', [$secondHalfStart, $secondHalfEnd])->field("sent_review_cost")->select()->toArray();
- $sent_review_cost = [
- 'first_sent_review_cost' => 0,
- 'second_sent_review_cost' => 0
- ];
- for ($i = 0; $i < count($first_sent_review_cost); $i++) {
- $a = $first_sent_review_cost[$i];
- $sent_review_cost["first_sent_review_cost"] += $a['sent_review_cost'];
- }
- for ($i = 0; $i < count($second_sent_review_cost); $i++) {
- $a = $second_sent_review_cost[$i];
- $sent_review_cost["second_sent_review_cost"] += $a['sent_review_cost'];
- }
- //评审服务费,上半年服务费用,下半年服务费用 end
- //项目数量,正在作业,已归档
- $num = Db::name("cost_project")->where([
- ["review_unit", "=", get_login_admin("unit_name")],
- ['delete_time', '=', 0],
- ["project_status", '>', 3],
- ])->count();
- $where = [
- ["review_unit", "=", get_login_admin("unit_name")],
- ['delete_time', '=', 0],
- ["project_status", ">", 3]
- ];
- $data = Db::name("cost_project")->where($where)->select();
- $num_project = [
- 'num' => 0,
- "yu" => 0,
- "jie" => 0,
- "zuo" => 0,
- "gui" => 0,
- "tui" => 0,
- ];
- foreach ($data as $key => $value) {
- $num_project["num"] += 1;
- if ($value["project_status"] < 6 && $value["project_status"] > 3) {
- $num_project["zuo"] += 1;
- }
- if ($value["engineering_type1"] == 1) {
- $num_project["yu"] += 1;
- }
- if ($value["engineering_type1"] == 2) {
- $num_project["jie"] += 1;
- }
- if ($value["project_status"] == 8) {
- $num_project["gui"] += 1;
- }
- if ($value["project_status"] == 9) {
- $num_project["tui"] += 1;
- }
- }
- //项目数量,正在作业,已归档
- View::assign("sent_review_cost", $sent_review_cost);
- View::assign("amount", $amount);
- View::assign("num", $num);
- View::assign("num_project", $num_project);
- View::assign("sent_review_amount_tol", $sent_review_amount_tol);
- return View();
- }
- }
|