wugg 2 years ago
parent
commit
13b4ccc976
3 changed files with 86 additions and 5 deletions
  1. 78 2
      app/admin/controller/InvCat.php
  2. 3 3
      app/admin/controller/Payment.php
  3. 5 0
      app/admin/route/app.php

+ 78 - 2
app/admin/controller/InvCat.php

@@ -8,15 +8,48 @@ use think\facade\Db;
 
 class InvCat extends BaseController{
     public function __construct(App $app) {parent::__construct($app);}
-
+    //商品关联开票类目
     public function AddGood(){
+            $spuCode=isset($this->post['spuCode'])&&$this->post['spuCode']!=''?trim($this->post['spuCode']):"";
+            if($spuCode==''){
+                return error_show(1004,"参数 spuCode 不能为空");
+            }
+            $goodinfo =Db::name("good")->where(["spuCode"=>$spuCode])->findOrEmpty();
+            if(empty($goodinfo)) return error_show(1004,"商品数据未找到");
+            $inv_good_name = isset($this->post['inv_good_name'])&&$this->post['inv_good_name']!=''?trim($this->post['inv_good_name']):"";
+            if($inv_good_name==''){
+                return error_show(1004,"参数 inv_good_name 不能为空");
+            }
+            $tax = isset($this->post['tax'])&&$this->post['tax']!=''?trim($this->post['tax']):"";
+            if($tax=="") return error_show(1004,"参数 tax 不能为空");
+            $cat_code = isset($this->post['cat_code'])&&$this->post['cat_code']!=''?trim($this->post['cat_code']):"";
+            if($cat_code==''){
+               return error_show(1004,"参数 cat_code 不能为空");
+            }
+            $catinfo=Db::name("inv_cat")->where(["cat_code"=>$cat_code])->findOrEmpty();
+            if(empty($catinfo)) return error_show(1004,"未找到对应的开票类目");
+            $taxArr=$catinfo['tax']!=''? explode("、",$catinfo['tax']):[];
+            if(!in_array($tax,$taxArr))return error_show(1004,"未找到对应的开票类目税率");
+            $data=[
+                "inv_cat_name"=>$catinfo['short_name'],
+                "inv_cat_code"=>$catinfo['merge_code'],
+                "inv_tax"=>$tax,
+                "inv_good_name"=>$inv_good_name,
+                "updatetime"=>date("Y-m-d H:i:s")
+            ];
+            $up =Db::name("good")->where($goodinfo)->update($data);
+            return $up? app_show(0,"添加成功"):error_show(1004,"添加失败");
 
     }
-
+    //商品列表
     public function GoodList(){
         $page =isset($this->post['page'])&&  $this->post['page']!="" ? intval($this->post['page']) :1;
         $size =isset($this->post['size'])&&  $this->post['size']!="" ? intval($this->post['size']) :15;
         $condition =[];
+        $status =isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):"";
+        if($status!==''){
+          $condition[]=["status","=",$status];
+        }
         $spuCode=isset($this->post['spuCode'])&&$this->post['spuCode']!=''?trim($this->post['spuCode']):"";
         if($spuCode!="") $condition[]=["spuCode","like","%$spuCode%"];
         $good_name=isset($this->post['good_name'])&&$this->post['good_name']!=''?trim($this->post['good_name']):"";
@@ -39,4 +72,47 @@ class InvCat extends BaseController{
         }
         return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
     }
+    //发票类目列表
+    public function catlist(){
+        $page =isset($this->post['page'])&&  $this->post['page']!="" ? intval($this->post['page']) :1;
+        $size =isset($this->post['size'])&&  $this->post['size']!="" ? intval($this->post['size']) :15;
+        $condition =[];
+        $cat_name = isset($this->post['cat_name'])&&$this->post['cat_name']!=''?trim($this->post['cat_name']):"";
+        if($cat_name!=''){
+            $condition[]=["cat_name|short_name","like","%$cat_name%"];
+        }
+        $cat_code = isset($this->post['cat_code'])&&$this->post['cat_code']!=''?trim($this->post['cat_code']):"";
+        if($cat_code!=''){
+            $condition[]=["cat_code|merge_code","like","%$cat_code%"];
+        }
+        $status =isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):"";
+        if($status!==''){
+          $condition[]=["status","=",$status];
+        }
+        $count =Db::name("inv_cat")->where($condition)->count();
+        $total=ceil($count/$size);
+        $page = $page>=$total? intval($total):$page;
+        $list =Db::name("inv_cat")->where($condition)->order("addtime desc")->page($page,$size)->select()->toArray();
+        foreach ($list as &$value){
+            $value['tax'] = $value['tax']==''?[]:explode("、",$value['tax']);
+        }
+        return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
+    }
+    //类目查询
+    public function query(){
+       $condition =[];
+        $cat_name = isset($this->post['cat_name'])&&$this->post['cat_name']!=''?trim($this->post['cat_name']):"";
+        if($cat_name!=''){
+            $condition[]=["cat_name|short_name","like","%$cat_name%"];
+        }
+        $cat_code = isset($this->post['cat_code'])&&$this->post['cat_code']!=''?trim($this->post['cat_code']):"";
+        if($cat_code!=''){
+            $condition[]=["cat_code|merge_code","like","%$cat_code%"];
+        }
+       $list =Db::name("inv_cat")->where($condition)->order("addtime desc")->limit(30)->select()->toArray();
+        foreach ($list as &$value){
+            $value['tax'] = $value['tax']==''?[]:explode("、",$value['tax']);
+        }
+      return app_show(0,"获取成功",$list);
+    }
 }

+ 3 - 3
app/admin/controller/Payment.php

@@ -949,7 +949,7 @@ class Payment extends BaseController
 
     /**
  * 发票审核状态
- *  0 上传发票,1待识别验证 2 待校验识别 3 待财务审核 6 待认证 7认证成功待确认完成 8回票完成 9识别失败 10 验证失败 11 财务驳回 12 认证失败 13校验超过次数 第二天校验
+ *  0 上传发票,1待识别验证 2 待校验识别 3 待财务审核 4待认证 5认证成功待确认完成 6回票完成7识别失败 8 验证失败 9 财务驳回 10 认证失败 11校验超过次数第二天校验 12 回票申请废弃已结束
      * @return \think\response\Json|void
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
@@ -995,7 +995,7 @@ class Payment extends BaseController
             $invup =["status"=>$status,"remark"=>$remark,"updatetime"=>date("Y-m-d H:i:s")];
             $inv =Db::name("pay_invoice")->where($payment)->update($invup);
             if($inv){
-                if($status==8){
+                if($status==6){
                       $payupdate =[
                             "ainv_fee"=>$payinfo['ainv_fee']+$payment['inv_fee'],
                             "inv_fee"=>$payinfo['inv_fee']-$payment['inv_fee'],
@@ -1008,7 +1008,7 @@ class Payment extends BaseController
                             return error_show(1003,"回票申请状态更新成功");
                         }
                 }
-                if($status==11){
+                if($status==9 || $status==10){
                     $payupdate =[
                             "winv_fee"=>$payinfo['winv_fee']+$payment['inv_fee'],
                             "inv_fee"=>$payinfo['inv_fee']-$payment['inv_fee'],

+ 5 - 0
app/admin/route/app.php

@@ -131,6 +131,11 @@ Route::rule("tagdel","admin/TagGood/delete");
 Route::rule("tagedit","admin/TagGood/save");
 Route::rule("addtag","admin/TagGood/AddTag");
 
+Route::rule("goodlist","admin/InvCat/GoodList");
+Route::rule("catlist","admin/InvCat/catlist");
+Route::rule("catquery","admin/InvCat/query");
+Route::rule("addgood","admin/InvCat/AddGood");
+