wuggemail@foxmail.com 3 weeks ago
parent
commit
5899d7dc2b

+ 2 - 1
app/admin/command/EveryCompanyInv.php

@@ -55,6 +55,7 @@ class EveryCompanyInv extends Command
     public function getInv($companyNo, Output $output)
     {
         $invTotal = [
+            "id"=>CompanyInv::where([["companyNo","=",$companyNo],["day_time","=",$this->date]])->value("id"),
             "day_time"=> $this->date,
             'companyNo'=>$companyNo,
             'companyName'=>$this->companyArr[$companyNo],
@@ -67,7 +68,7 @@ class EveryCompanyInv extends Command
         $this->cgdInv($invTotal);
         $this->qrdInvReturn($invTotal);
         $this->cgdInvReturn($invTotal);
-        CompanyInv::create($invTotal);
+        (new \app\admin\model\CompanyInv)->save($invTotal);
     }
     public function qrdInv(&$invTotal)
     {

+ 13 - 0
app/admin/controller/Everyday.php

@@ -4,6 +4,7 @@ declare (strict_types = 1);
 namespace app\admin\controller;
 
 use app\account\model\Headquarters;
+use app\admin\model\AccountInvTips;
 use app\admin\model\CompanyInv;
 use app\admin\model\CompanyInvTips;
 use app\admin\model\EverydayCompany;
@@ -420,6 +421,12 @@ class Everyday extends Auth
                     ->field("inv_fee,return_inv_fee,cost_fee,return_cost_fee")
                     ->findOrEmpty();
                 $item['dayinfo'] = $dayinfo->isEmpty()?$temp:$dayinfo->toArray();
+                $tips= AccountInvTips::where("uid",$item['uid'])
+                    ->where("year", date("Y",strtotime($param['daytime'])))
+                    ->where("month", date("m",strtotime($param['daytime'])))
+                    ->field("inv_tips,cost_tips")
+                    ->findOrEmpty();
+                $item['tips'] = $tips->isEmpty()?["inv_tips"=>"0","cost_tips"=>"0"]:$tips->toArray();
             });
         $this->success('获取成功',$list,0);
     }
@@ -432,9 +439,13 @@ class Everyday extends Auth
             'uid'=>'require|max:255'
         ]);
         if($valid!==true) $this->error($valid);
+        $tips = [];
         if($param['uid']!="")  {
             $where[]=['uid','=',$param['uid']];
             $uname = \app\account\model\User::where("account_id",$param['uid'])->value("nickname",'');
+            $tips = AccountInvTips::where("uid",$param['uid'])
+                ->where("year", $param['year'])
+                ->column("inv_tips,cost_tips","month");
         }
 
         $month = [];
@@ -455,6 +466,8 @@ class Everyday extends Auth
                 "month_return_cost_fee"=>$monthinfo->month_return_cost_fee,
                 "uname"=>$monthinfo->uname??$uname,
                 "uid"=>$monthinfo->uid??$param['uid'],
+                "inv_tips"=>$tips[$v['month']]['inv_tips']??0,
+                "cost_tips"=>$tips[$v['month']]['cost_tips']??0
             ];
        }
         return  $this->success('获取成功',$data,0);

+ 73 - 0
app/admin/controller/Tips.php

@@ -5,6 +5,7 @@ namespace app\admin\controller;
 
 
 use app\account\model\CompanyItem;
+use app\admin\model\AccountInvTips;
 use app\admin\model\CompanyInvTips;
 use app\admin\model\CompanyTips;
 use app\admin\model\DepartTips;
@@ -244,4 +245,76 @@ class Tips extends Auth{
         (new CompanyInvTips)->saveAll($list);
         $this->success("导入成功");
     }
+
+    //开票指标
+    public function account_inv_list(){
+        $params = $this->request->param(["uid"=>"","month"=>"","year"=>"","page"=>1,"size"=>15],"post","trim");
+        $where=[];
+        if ($params["uid"]!=="") $where[]=["uid","=",$params["uid"]];
+        if ($params["month"]!=="") $where[]=["month","=",$params["month"]];
+        if ($params["year"]!=="") $where[]=["year","=",$params["year"]];
+        $data = AccountInvTips::where($where)->order("id desc")->paginate(["page"=>$params['page'],"list_rows"=>$params['size']]);
+        $this->success("获取成功",["list"=>$data->items(),"count"=>$data->total()]);
+    }
+    public function account_inv_create(){
+        $params = $this->request->param(["uid"=>"","month"=>"","year"=>"","inv_tips"=>"","cost_tips"=>""],"post","trim");
+        $valid = Validate::rule([
+            "uid|用户id"=>"require|number",
+            "month|月份"=>"require|max:255|unique:app\admin\model\AccountInvTips,uid^month^year",
+            "year|年份"=>"require|max:255",
+            "inv_tips|开票指标"=>"require|float",
+            "cost_tips|毛利指标"=>"require|float",
+        ]);
+        if (!$valid->check($params)) $this->error($valid->getError(),1004);
+        $params["creater"] = $this->uname;
+        $params['uname'] = \app\account\model\User::where('account_id',$params['uid'])->value('nickname','');
+        AccountInvTips::create($params);
+        $this->success("添加成功");
+    }
+
+    public function account_inv_update(){
+        $params = $this->request->param(["id"=>"","inv_tips"=>"","cost_tips"=>""],"post","trim");
+        $valid = Validate::rule([
+            "id|id"=>"require|integer",
+            "inv_tips|开票指标"=>"require|float",
+            "cost_tips|毛利指标"=>"require|float",
+        ]);
+        if (!$valid->check($params)) $this->error($valid->getError(),1004);
+        $info = AccountInvTips::where(["id"=>$params['id']])->findOrEmpty();
+        if ($info->isEmpty()) $this->error('数据不存在');
+        $info->save($params);
+        $this->success("修改成功");
+    }
+    public function account_inv_delete(){
+        $params = $this->request->param(["id"=>""],"post","trim");
+        $valid = Validate::rule([
+            "id|id"=>"require|integer",
+        ]);
+        if (!$valid->check($params)) $this->error($valid->getError(),1004);
+        $info = AccountInvTips::where(["id"=>$params['id']])->findOrEmpty();
+        if ($info->isEmpty()) $this->error('数据不存在');
+        $info->delete();
+        $this->success("删除成功");
+    }
+    public function account_inv_import(){
+        $list = $this->request->param("list",'post','trim');
+        $valid = Validate::rule([
+            "list|数据"=>"require|array",
+        ]);
+        if (!$valid->check($list)) $this->error($valid->getError(),1004);
+        $valids = Validate::rule([
+            'uid|用户id'=>'require|number',
+            'month|月份'=>'require|max:255|unique:app\admin\model\AccountInvTips,uid^month^year',
+            'year|年份'=>'require|max:255',
+            'inv_tips|开票指标'=>'require|float',
+            'cost_tips|毛利指标'=>'require|float',
+        ]);
+        foreach ($list as &$item){
+            if (!$valids->check($item)) $this->error($valids->getError(),1004);
+            $item['creater'] = $this->uname;
+            $item['companyName'] = \app\account\model\User::where("account_id",$item['uid'])->value('nickname','');
+        }
+        (new AccountInvTips)->saveAll($list);
+        $this->success("导入成功");
+    }
 }

+ 1 - 1
app/admin/model/AccountInv.php

@@ -11,7 +11,7 @@ class AccountInv extends Model
         'id' => 'int',
         'uid' => 'int',
         'uname' => 'string',
-        'day_time' => 'string',
+        'day_time' => 'date',
         'inv_fee' => 'float',
         'return_inv_fee' => 'float',
         'cost_fee'=>'float',

+ 22 - 0
app/admin/model/AccountInvTips.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+class AccountInvTips Extends Model
+{
+    protected $schema = [
+        'id' => 'int',
+        'uid' => 'int',
+        'uname' => 'string',
+        'year'=> 'year',
+        'month' => 'month',
+        'inv_tips' => 'float',
+        'cost_tips' => 'float',
+        'creater' => 'string',
+        'createtime' => 'datetime'
+    ];
+    protected $createTime = 'createtime';
+
+}

+ 1 - 1
app/admin/model/CompanyInv.php

@@ -12,7 +12,7 @@ class CompanyInv extends Model
         'id' => 'int',
         'companyNo' => 'string',
         'companyName' => 'string',
-        'day_time' => 'string',
+        'day_time' => 'date',
         'inv_fee' => 'float',
         'return_inv_fee' => 'float',
         'cost_fee'=>'float',