wugg преди 1 година
родител
ревизия
3716b70bf0
променени са 47 файла, в които са добавени 512 реда и са изтрити 209 реда
  1. 0 26
      app/admin/BaseController.php
  2. 5 3
      app/admin/command/downredinvres.php
  3. 2 2
      app/admin/controller/Action.php
  4. 2 2
      app/admin/controller/ActionProcess.php
  5. 140 0
      app/admin/controller/Base.php
  6. 2 2
      app/admin/controller/Company.php
  7. 2 2
      app/admin/controller/Customer.php
  8. 2 2
      app/admin/controller/DataGroup.php
  9. 2 2
      app/admin/controller/DataShare.php
  10. 1 1
      app/admin/controller/DepartTips.php
  11. 1 1
      app/admin/controller/Exec.php
  12. 1 1
      app/admin/controller/ExecStat.php
  13. 2 2
      app/admin/controller/Export.php
  14. 103 0
      app/admin/controller/Good.php
  15. 2 2
      app/admin/controller/Group.php
  16. 1 1
      app/admin/controller/InterOrder.php
  17. 3 3
      app/admin/controller/InvCat.php
  18. 1 1
      app/admin/controller/Login.php
  19. 2 2
      app/admin/controller/Menu.php
  20. 3 7
      app/admin/controller/OrderInv.php
  21. 2 2
      app/admin/controller/OrderPay.php
  22. 8 2
      app/admin/controller/Payment.php
  23. 2 2
      app/admin/controller/Process.php
  24. 2 2
      app/admin/controller/Report.php
  25. 2 2
      app/admin/controller/Role.php
  26. 2 2
      app/admin/controller/Sale.php
  27. 2 2
      app/admin/controller/Share.php
  28. 1 1
      app/admin/controller/Stat.php
  29. 2 2
      app/admin/controller/Supplier.php
  30. 1 1
      app/admin/controller/System.php
  31. 2 2
      app/admin/controller/TagGood.php
  32. 1 1
      app/admin/controller/Upload.php
  33. 2 2
      app/admin/controller/User.php
  34. 0 1
      app/admin/controller/WeChat.php
  35. 0 48
      app/admin/middleware/checkRela.php
  36. 3 68
      app/admin/middleware/checkToken.php
  37. 14 0
      app/admin/model/CgdInfo.php
  38. 14 0
      app/admin/model/CompanyInfo.php
  39. 40 0
      app/admin/model/Good.php
  40. 14 0
      app/admin/model/InvCat.php
  41. 14 0
      app/admin/model/InvoiceGood.php
  42. 14 0
      app/admin/model/QrdInfo.php
  43. 14 0
      app/admin/model/SupplierInfo.php
  44. 14 0
      app/admin/model/SystemLog.php
  45. 7 3
      app/command/good.php
  46. 58 3
      app/common.php
  47. 0 1
      app/middleware.php

+ 0 - 26
app/admin/BaseController.php

@@ -1,26 +0,0 @@
-<?php
-namespace  app\admin;
-use think\App;
-use app\BaseController as base;
-use think\facade\Db;
-/**
-* Class BaseController
- * @package app\admin
- * 基础控制器
- */
-class BaseController extends base{
-    public  $post=[];
-    public  $uid='';
-    public  $uname='';
-    public  $roleid='';
-    public  $level='';
-    public function __construct(App $app) {
-         parent::__construct($app);
-         $this->uid = $this->request->uid;
-         $this->uname = $this->request->uname;
-         $this->roleid = $this->request->roleid;
-         $this->level = $this->request->level;
-         $this->post =$this->request->post();
-     }
-
-}

+ 5 - 3
app/admin/command/downredinvres.php

@@ -83,9 +83,11 @@ class downredinvres extends Command
 			}
 		}else{
 			$data['remark']=$result['ZTXX'];
-			$data['status']=5;
-			Db::name("invoice_red")->where(["id"=>$row['id']])->update($data);
-			$this->updateReturn($row['returnCode'],$result['ZTXX']);
+			if(!isset($result['ZTDM']) || $result['ZTDM']!='060111'){
+				$data['status']=5;
+				$this->updateReturn($row['returnCode'],$result['ZTXX']);
+			}
+			Db::name('invoice_red')->where(['id'=>$row['id']])->update($data);
 		}
 
 		Db::commit();

+ 2 - 2
app/admin/controller/Action.php

@@ -1,11 +1,11 @@
 <?php
 declare (strict_types = 1);
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;
 
-class Action extends BaseController{
+class Action extends Base{
     public function __construct(App $app) {parent::__construct($app);}
 
     //获取素有菜单列表数据

+ 2 - 2
app/admin/controller/ActionProcess.php

@@ -2,7 +2,7 @@
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use app\admin\model\ProcessWait;
 use think\facade\Db;
 use think\facade\Validate;
@@ -10,7 +10,7 @@ use app\admin\model\ActionProcess as APModel;
 use app\admin\model\Process as PModel;
 
 //流程节点
-class ActionProcess extends BaseController
+class ActionProcess extends Base
 {
 
     //获取流程节点列表

+ 140 - 0
app/admin/controller/Base.php

@@ -0,0 +1,140 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\controller;
+
+use app\BaseController;use think\App;use think\exception\HttpResponseException;use think\Response;
+
+class Base extends BaseController
+{
+	protected $novalidate=[
+		'systemlast',
+		'login',
+		'stats',
+		'departstat',
+		'departEveryDay',
+		'departEveryMonth',
+		'companyEveryMonth',
+		'dzqrd',
+		'companyEvery',
+		'wechat_getinfo',
+		'wechat_getconfig',
+		'totalstat'
+		];
+	public $supperAction=[
+	        'payadd',#对账新建
+	        'paysave',#对账编辑
+	        'paydel',#对账删除
+	        'invadd',#回票申请新建
+	        'invAddBatchByImport',#回票申请批量
+	        'invdel',#回票申请删除
+	        'hpinvreturn', #回票申请退票
+	        'stagereturn',#付款申请退款
+    	];
+	protected  $uid=0;
+	protected  $uname='';
+	protected  $roleid=0;
+	protected  $level=0;
+  public function __construct(App $app) {
+  	parent::__construct($app);
+  	 if(!in_array($this->request->pathinfo(),$this->novalidate)&&!in_array('*', $this->novalidate)){
+        $this->validateToken($this->request->param());
+  	 }
+  }
+  
+   /**
+	* @param string $message
+	* @param int $code
+	* @param null $data
+	 */
+    public function error($message='',$code=1003,$data=null){
+        $this->result($message,$data,$code);
+    }
+
+     /**
+	* @param string $msg
+	* @param null $data
+	* @param int $code
+	* @param string|null $type
+	* @param array $header
+	* @param array $options
+	 */
+    private function result(string $msg, $data = null, int $code = 0, string $type = 'json', array $header = [], array
+    $options = [])
+    {
+        $result = [
+            'code' => $code,
+            'message'  => $msg,
+            'data' => $data,
+        ];
+        $code = 200;
+        if (isset($header['statuscode'])) {
+            $code = $header['statuscode'];
+            unset($header['statuscode']);
+        }
+
+        $response = Response::create($result, $type, $code)->header($header)->options($options);
+         throw new HttpResponseException($response);
+    }
+    
+    /**
+	* @param string $message
+	* @param int $code
+	* @param null $data
+	 */
+     public function success($message='',$data=null,$code=0){
+        $this->result($message,$data,$code);
+    }
+    /**
+* @param $request 校验用户信息
+* @throws \think\db\exception\DataNotFoundException
+* @throws \think\db\exception\DbException
+* @throws \think\db\exception\ModelNotFoundException
+* @throws \think\exception\DbException
+ */
+     public function validateToken($request){
+            $token = $request['token']?? '';
+            $companyNo = $request['relaComNo'] ?? '';
+            if($token=='') $this->error('参数token不能为空','101');
+            $effetc = VerifyTokens($token);
+            if(!empty($effetc) && $effetc['code']!=0)$this->error($effetc['message'],$effetc['code']);
+            $this->uid=$effetc['data']['id']??'';
+            $this->uname=$effetc['data']['nickname']??'';
+            $where=[];
+            if($companyNo!=''){
+            	$where=['companyNo'=>$companyNo];
+            }
+            $userrole = \app\admin\model\UserRole::where(['uid'=>$this->uid,'is_del'=>0])->where($where)
+            ->findOrEmpty();
+            if($userrole->isEmpty()){
+            	 $this->error("账户已禁用",'101');
+            }
+            $this->roleid=$userrole->roleid;
+            $role =\app\admin\model\Role::where(['id'=>$userrole->roleid])->findOrEmpty();
+            if($role->status==0 || $userrole->status==0 ){
+            	$this->level=0;
+            }else $this->level = $effetc['data']['level'];
+            
+     }
+     //供应商公司存在操作账户,请用供应商账户操作
+     public function NoAction(){
+     	$pathinfo =$this->request->pathinfo();
+		$relaComNo =$this->request->param('relaComNo');
+        if (in_array($this->level, [2, 3])) {
+            if (in_array($pathinfo, $this->supperAction) && $this->level == 2) {
+                if ($relaComNo == '')  $this->error('关联公司不能为空');
+                $companyinfo = UserHandle('/hqInfo', ['code' => $relaComNo]);
+                if ($companyinfo['code'] != 0)$this->error($companyinfo['message'],$companyinfo['code']);
+                if (!empty($companyinfo['data']) && $companyinfo['data']['relation_code'] != '') {
+                 $db= UserHandle('/userCompanyBasicList', ['companyNo' =>$companyinfo['data']['relation_code']]);
+	                if ($db['code'] != 0) $this->error($db['message'],$db['code']);
+	                if (!empty($db['data']) && $db['data']['count'] > 0) {
+	                	$this->error("供应商公司存在操作账户,请用供应商账户操作");
+//	                    return error_show(1004,"供应商公司存在操作账户,请用供应商账户操作");
+	                }
+
+                }
+            }
+        }
+     }
+}

+ 2 - 2
app/admin/controller/Company.php

@@ -2,12 +2,12 @@
 declare (strict_types = 1);
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Config;use think\facade\Db;
 
 
-class Company extends BaseController
+class Company extends Base
 {
 	protected $invoiceType;
     public function __construct(App $app) {

+ 2 - 2
app/admin/controller/Customer.php

@@ -2,10 +2,10 @@
 declare (strict_types = 1);
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\facade\Db;
 
-class Customer extends BaseController
+class Customer extends Base
 {
     /**
      * 获取企业客户列表

+ 2 - 2
app/admin/controller/DataGroup.php

@@ -3,13 +3,13 @@
 namespace app\admin\controller;
 
 //用户组
-use app\admin\BaseController;
+
 use think\Exception;
 use think\facade\Db;
 use think\facade\Validate;
 use app\admin\model\DataGroup as DataGroupModel;
 
-class DataGroup extends BaseController
+class DataGroup extends Base
 {
 
     //用户组列表

+ 2 - 2
app/admin/controller/DataShare.php

@@ -2,14 +2,14 @@
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use think\facade\Db;
 use think\facade\Validate;
 use app\admin\model\DataShare as DataShareModel;
 use app\admin\model\DataGroup as DataGroupModel;
 
 //数据共享规则
-class DataShare extends BaseController
+class DataShare extends Base
 {
 
     //列表

+ 1 - 1
app/admin/controller/DepartTips.php

@@ -8,7 +8,7 @@ use think\App;
 use think\Exception;
 use think\facade\Db;
 use think\facade\Validate;
-class DepartTips extends \app\admin\BaseController{
+class DepartTips extends Base{
 	public function __construct(App $app) {parent::__construct($app);}
 
 	public function list(){

+ 1 - 1
app/admin/controller/Exec.php

@@ -6,7 +6,7 @@ namespace app\admin\controller;
 use think\facade\Db;
 use think\App;
 use think\facade\Validate;
-class Exec extends \app\admin\BaseController{
+class Exec extends Base{
 
 	public function __construct(App $app) {parent::__construct($app);}
 

+ 1 - 1
app/admin/controller/ExecStat.php

@@ -7,7 +7,7 @@ namespace app\admin\controller;
 use think\App;
 use think\facade\Db;
 use think\facade\Validate;
-class ExecStat extends \app\admin\BaseController{
+class ExecStat extends Base{
 	public function __construct(App $app) {parent::__construct($app);}
 
 	public function list(){

+ 2 - 2
app/admin/controller/Export.php

@@ -2,13 +2,13 @@
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;
 use think\facade\Validate;
 
 //报表导出相关
-class Export extends BaseController
+class Export extends Base
 {
 
     //相关字段的文字转换

+ 103 - 0
app/admin/controller/Good.php

@@ -0,0 +1,103 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\controller;
+
+use think\App;use think\facade\Validate;
+class Good extends Base
+{
+	protected $model=null;
+    public function __construct(App $app) {
+    	parent::__construct($app);
+    	$this->model=new \app\admin\model\Good();
+    }
+    /** 商品列表
+	* @throws \think\db\exception\DbException
+	* @throws \think\exception\DbException
+	 */
+    public function list(){
+    	$param=$this->request->param(["spuCode"=>"","status"=>"","good_name"=>"",'companyNo'=>'','supplierNo'=>'',
+    	'creater'=>'','isZx'=>'',"cat_diff"=>"","tax_diff"=>"",'page'=>'1','size'=>'15'],"post","trim");
+    	$where=[];
+    	$param["spuCode"]==""?? $where[]=['spuCode','like',"%{$param['spuCode']}%"];
+    	$param["good_name"]==""?? $where[]=['good_name','like',"%{$param['good_name']}%"];
+    	$param["companyNo"]==""?? $where[]=['companyNo','like',"%{$param['companyNo']}%"];
+    	$param["supplierNo"]==""?? $where[]=['supplierNo','like',"%{$param['supplierNo']}%"];
+    	$param["creater"]==""?? $where[]=['creater','like',"%{$param['creater']}%"];
+    	$param["status"]===""?? $where[]=['status','=',$param['status']];
+    	$param["isZx"]==""?? $where[]=['isZx','=',$param['isZx']];
+    	$list= $this->model->where($where)->order("id desc")
+    	->paginate(["page"=>$param['page'],"list_rows"=>$param["size"]]);
+    	$this->success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
+    }
+    //批量更新数据状态审核
+    public function exam(){
+        $param=$this->request->param(["list"=>[],"status"=>""],"post","trim");
+        $valid=Validate::rule(["list|审核数据集"=>"require|array","status|状态"=>"require|number|in:1,2"]);
+        if($valid->check($param)==false)$this->error($valid->getError());
+        $validList=Validate::rule([
+        	        'spuCode|商品编号' => 'require|max:255',
+                    'tax|税率' => 'require|max:4',
+                    'cat_code|类目编号简写' => 'require|max:255',
+                    'inv_good_name|开票商品名称' => 'require|max:255',
+                    'inv_tag|税率标识' => 'requireIf:status,2|between:0,3',
+                    'is_discount|是否有优惠政策' => 'requireIf:status,2|in:0,1',
+                    'addTax|增值税管理内容' => 'max:255']);
+        $goodUpdate=[];
+        $catArr = \app\admin\model\InvCat::where(["cat_code"=>array_unique(array_column($param['list'],"cat_code"))])
+         ->column('tax,merge_code,short_name', 'cat_code');
+        foreach ($param['list'] as $item){
+        	$temp=[];
+        	$item['status'] = $param['status'];
+        	if($validList->check($item)==false) $this->error("商品{$item['spuCode']}".$validList->getError());
+        	$good=$this->model->where(["spuCode"=>$item['spuCode']])->findOrEmpty();
+        	if($good->isEmpty())$this->error("商品信息{$item['spuCode']}不存在");
+        	if(!isset($catArr[$item['cat_code']]))$this->error("商品{$item['spuCode']}所选类目不存在");
+        	$tax = $catArr[$item['cat_code']]['tax']==""?[]:explode('、', $catArr[$item['cat_code']]['tax']);
+        	if(!in_array($item['tax'],$tax))$this->error("商品{$item['spuCode']}所选税率与类目包含税率不一致");
+        	//采购端修改 只能在待财务设置税务类目状态 切该商品未参与采购付款回票对账
+        	//销售端修改 只要没参与销售回款开票结算
+        	$temp['id']=$good->id;
+        	$temp['status']=$param['status'];
+        	if($param['status']<$good->status) $this->error("商品{$item['spuCode']}当前状态".\app\admin\model\Good::$status[$good->status]."不可修改");
+             $item['tax'] = bcdiv(str_replace('%', '', $item['tax']), "100", 2);
+        	if($param['status']==1){
+        		if($good->cgd_to_pay)$this->error("商品{$item['spuCode']}已参与采购付款回票对账");
+        	    $temp["cgd_inv_cat_code"]=$catArr[$item['cat_code']]['merge_code'];
+        	    $temp["cgd_inv_cat_name"]=$catArr[$item['cat_code']]['short_name'];
+        	    $temp["cgd_inv_good_name"]= $item['inv_good_name'];
+        	    $temp["cgd_inv_tax"]= $item['tax'];
+        	}
+        	if($param['status']==2){
+        	    if($good->qrd_to_pay)$this->error("商品{$item['spuCode']}已参与销售回款开票结算");
+        	    $check = CheckTax($item['is_discount'],$item['tax'],$item['inv_tag'],
+        	    $item['addTax'],$message);
+        	    if($check==false)$this->error("商品{$item['spuCode']}{$message}");
+        	    $temp['inv_cat_code']=$catArr[$item['cat_code']]['merge_code'];
+        	    $temp['inv_cat_name']=$catArr[$item['cat_code']]['short_name'];
+        	    $temp['inv_good_name']= $item['inv_good_name'];
+        	    $temp['inv_tax']= $item['tax'];
+        	    $temp['is_discount']= $item['is_discount'];
+        	    $temp['addTax']= $item['addTax'];
+        	    $temp['inv_tag']= $item['inv_tag'];
+        	    $temp['tax_diff']= $item['tax']==$good->cgd_inv_tax?1:2;
+        	    $temp['cat_diff']= $temp['inv_cat_code']==$good->cgd_inv_cat_code?1:2;
+        	}
+        	$examinfo=$good->exam_info;
+        	$examinfo[]=['apply_name'=>$this->uname,'exam_status'=>$item['status'],"updatetime"=>date("Y-m-d H:i:s")];
+        	$temp['exam_info'] = json_encode($examinfo,JSON_UNESCAPED_UNICODE);
+        	$goodUpdate[]=$temp;
+        }
+        $this->model->saveAll($goodUpdate);
+        $this->success("更新成功");
+    }
+    //商品信息
+    public function info(){
+        $param=$this->request->param(['spuCode'=>''],'post','trim');
+        $valid=Validate::rule(['spuCode|商品成本编号'=>'require|max:255']);
+        if($valid->check($param)==false)$this->error($valid->getError());
+        $info = $this->model->where(["spuCode"=>$param['spuCode']])->findOrEmpty();
+        if($info->isEmpty())$this->error("商品信息不存在");
+        $this->success("获取成功",$info);
+    }
+}

+ 2 - 2
app/admin/controller/Group.php

@@ -1,10 +1,10 @@
 <?php
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;
 
-class Group extends BaseController
+class Group extends Base
 {
     public function __construct(App $app) {parent::__construct($app);}
     /**分组列表分页

+ 1 - 1
app/admin/controller/InterOrder.php

@@ -6,7 +6,7 @@ namespace app\admin\controller;
 use think\facade\Db;
 use think\facade\Validate;
 use think\App;
-class InterOrder extends \app\admin\BaseController{
+class InterOrder extends Base{
 	 public function __construct(App $app) {
 	 	parent::__construct($app);
 	 }

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

@@ -2,13 +2,13 @@
 
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\Exception;
 use think\facade\Db;
 use think\facade\Validate;
 
-class InvCat extends BaseController{
+class InvCat extends Base{
 	private $Tax=[0=>'',1=>"免税",2=>"不征税",3=>"零税率"];
     public function __construct(App $app) {parent::__construct($app);}
     //商品关联开票类目
@@ -75,7 +75,7 @@ class InvCat extends BaseController{
                 "inv_tag"=>$invTag,
                 "is_discount"=>$is_discount,
                 "addTax"=>$this->Tax[$addTax],
-                "status"=>1,
+                "status"=>2,
                 "updatetime"=>date("Y-m-d H:i:s")
             ];
             $up =Db::name("good")->where($goodinfo)->update($data);

+ 1 - 1
app/admin/controller/Login.php

@@ -7,7 +7,7 @@ namespace app\admin\controller;
 use think\App;
 use think\facade\Validate;
 use think\facade\Db;
-class Login extends \app\BaseController{
+class Login extends Base{
 		public function __construct(App $app) {parent::__construct($app);}
 
 		public function login(){

+ 2 - 2
app/admin/controller/Menu.php

@@ -1,12 +1,12 @@
 <?php
 declare (strict_types = 1);
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;
 use think\facade\Validate;
 
-class Menu extends BaseController{
+class Menu extends Base{
     public function __construct(App $app) {
     	parent::__construct($app);
     }

+ 3 - 7
app/admin/controller/OrderInv.php

@@ -2,7 +2,7 @@
 
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use app\admin\model\InvoiceInterface;use app\admin\model\ReportCode;
 use think\App;
 use think\Exception;
@@ -11,7 +11,7 @@ use think\facade\Db;
 use think\facade\Cache;
 use think\facade\Validate;
 
-class OrderInv extends BaseController{
+class OrderInv extends Base{
 	protected $typename;
 	protected $invoiceType;
     protected $invName;
@@ -55,10 +55,6 @@ class OrderInv extends BaseController{
        if($company==false){
            return error_show(1004,"销售方信息未找到");
        }
-//       $supplier = Db::name("supplier_info")->where(["code"=>$companyNo])->find();
-//       if($supplier==false){
-//           return error_show(1004,"业务公司信息未找到");
-//       }
        $invtype = isset($this->post['invtype'])&&$this->post['invtype']!=='' ? trim($this->post['invtype']):"";
         if($invtype==''){
            return error_show(1004,"参数 invtype 不能为空");
@@ -112,7 +108,7 @@ class OrderInv extends BaseController{
                     	Db::rollback();
                         return error_show(1004,"确认单{$value['sequenceNo']}待开票数量不足");
                     }
-                    $good_info = Db::name("good")->where(["spuCode"=>$qrd["goodNo"],"status"=>1])->findOrEmpty();
+                    $good_info = Db::name("good")->where(["spuCode"=>$qrd["goodNo"],"status"=>2])->findOrEmpty();
                     if(empty($good_info)){
                      Db::rollback();
                      return error_show(1004,"确认单{$value['sequenceNo']}商品未确认开票类目");

+ 2 - 2
app/admin/controller/OrderPay.php

@@ -2,14 +2,14 @@
 
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use app\admin\model\ReportCode;use think\App;
 use think\Exception;
 use think\facade\Db;
 use think\facade\Validate;
 use think\queue\command\Retry;
 
-class OrderPay extends BaseController{
+class OrderPay extends Base{
     public function __construct(App $app) {parent::__construct($app);}
         //新建资金认领数据
     public function create(){

+ 8 - 2
app/admin/controller/Payment.php

@@ -3,14 +3,14 @@ declare (strict_types = 1);
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use app\admin\model\ReportCode;
 use think\App;use think\Exception;
 use think\facade\Config;
 use think\facade\Db;
 use think\facade\Validate;
 
-class Payment extends BaseController
+class Payment extends Base
 {
     protected $invoiceType;
 
@@ -302,6 +302,12 @@ class Payment extends BaseController
                 "updatetime"=>date("Y-m-d H:i:s"),
             ];
            foreach ($cgdall as $key=>$value){
+           	$good_info = \app\admin\model\Good::where(['spuCode'=>$qrd['goodNo']])->findOrEmpty();
+             if($good_info->isEmpty()|| $good_info->status==0){
+                Db::rollback();
+               return error_show(1004,"采购单商品{$value['goodNo']}商品未确认开票类目");
+              }
+
                $temp=[];
                $temp['cgdNo']=$value['sequenceNo'];
                $temp['total_fee']=$value['totalPrice'];

+ 2 - 2
app/admin/controller/Process.php

@@ -3,7 +3,7 @@
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;
 use think\facade\Validate;
@@ -11,7 +11,7 @@ use app\admin\model\Process as ProcessModel;
 use app\admin\model\ActionProcess as APModel;
 
 //流程
-class Process extends BaseController
+class Process extends Base
 {
 
     //获取流程列表

+ 2 - 2
app/admin/controller/Report.php

@@ -3,11 +3,11 @@ declare (strict_types = 1);
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use think\Request;
 use think\facade\Db;
 
-class Report extends BaseController
+class Report extends Base
 {
     /**
      * 显示资源列表

+ 2 - 2
app/admin/controller/Role.php

@@ -2,14 +2,14 @@
 
 declare (strict_types = 1);
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use app\admin\model\ActionProcess as APModel;
 use app\admin\model\Process as PModel;
 use think\App;
 use think\facade\Db;
 use think\facade\Validate;
 
-class Role extends BaseController{
+class Role extends Base{
 
     public function __construct(App $app) {parent::__construct($app);}
     /**角色权限列表分页  page size

+ 2 - 2
app/admin/controller/Sale.php

@@ -2,10 +2,10 @@
 
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;use think\facade\Validate;
-class Sale extends BaseController{
+class Sale extends Base{
     public function __construct(App $app) {parent::__construct($app);}
     /** 获取列表
     * @return \think\response\Json|void

+ 2 - 2
app/admin/controller/Share.php

@@ -3,9 +3,9 @@ declare (strict_types = 1);
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use think\App;use think\facade\Db;
-class Share extends BaseController
+class Share extends Base
 {
     public function __construct(App $app) {parent::__construct($app);}
     /**

+ 1 - 1
app/admin/controller/Stat.php

@@ -10,7 +10,7 @@ use think\facade\Response;
 use think\helper\Arr;
 
 
-class Stat extends BaseController{
+class Stat extends Base{
 	public function __construct(App $app) {parent::__construct($app);}
 
 	public function stats(){

+ 2 - 2
app/admin/controller/Supplier.php

@@ -2,11 +2,11 @@
 declare (strict_types = 1);
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;
 
-class Supplier extends BaseController
+class Supplier extends Base
 {
     public function __construct(App $app) {parent::__construct($app);}
     /**

+ 1 - 1
app/admin/controller/System.php

@@ -3,7 +3,7 @@ declare (strict_types = 1);
 
 namespace app\admin\controller;
 
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Validate;
 use think\facade\Db;

+ 2 - 2
app/admin/controller/TagGood.php

@@ -2,11 +2,11 @@
 
 
 namespace app\admin\controller;
-use app\admin\BaseController;
+
 use think\App;
 use think\facade\Db;
 
-class TagGood extends BaseController{
+class TagGood extends Base{
     public function __construct(App $app) {parent::__construct($app);}
     //新建标签
     public function create(){

+ 1 - 1
app/admin/controller/Upload.php

@@ -4,7 +4,7 @@
 namespace app\admin\controller;
 use app\BaseController;use think\App;
 
-class Upload extends BaseController{
+class Upload extends Base{
  public function __construct(App $app) {parent::__construct($app);}
  //图片上传接口;
  public function UploadImg(){

+ 2 - 2
app/admin/controller/User.php

@@ -2,9 +2,9 @@
 
 declare (strict_types = 1);
 namespace app\admin\controller;
-use app\admin\BaseController;use think\App;use think\Exception;use think\facade\Db;use think\facade\Validate;
+use think\App;use think\Exception;use think\facade\Db;use think\facade\Validate;
 
-class User extends BaseController{
+class User extends Base{
  public function __construct(App $app) {parent::__construct($app);}
 	/**
       * 设置供应商信息

+ 0 - 1
app/admin/controller/WeChat.php

@@ -4,7 +4,6 @@
 namespace app\admin\controller;
 
 use think\App;
-use app\admin\BaseController as Base;
 use think\facade\Validate;
 use think\facade\Db;
 class WeChat extends Base {

+ 0 - 48
app/admin/middleware/checkRela.php

@@ -1,48 +0,0 @@
-<?php
-declare (strict_types = 1);
-
-namespace app\admin\middleware;
-class checkRela
-{
-    public $supperAction=[
-    	"admin/payadd",#对账新建
-    	"admin/paysave",#对账编辑
-    	"admin/paydel",#对账删除
-    	"admin/invadd",#回票申请新建
-    	"admin/invAddBatchByImport",#回票申请批量
-    	"admin/invdel",#回票申请删除
-    	"admin/hpinvreturn", #回票申请退票
-    	"admin/stagereturn",#付款申请退款
-    	];
-    /**
-		* @param $request
-		* @param \Closure $next
-	    * @return mixed|\think\response\Json|void
-	 */
-    public function handle($request, \Closure $next)
-    {
-		$pathinfo =$request->pathinfo();
-		$relaComNo =$request->param("relaComNo");
-        if (in_array($request->level, [2, 3])) {
-
-            if (in_array($pathinfo, $this->supperAction) && $request->level == 2) {
-
-                if ($relaComNo == '') return error_show(1004, "关联公司不能为空");
-                $companyinfo = UserHandle("/hqInfo", ["code" => $relaComNo]);
-                if ($companyinfo['code'] != 0) return error_show($companyinfo['code'], $companyinfo['message']);
-                if (!empty($companyinfo['data']) && $companyinfo['data']['relation_code'] != "") {
-                 $db= UserHandle("/userCompanyBasicList", ["companyNo" =>$companyinfo['data']['relation_code']]);
-	                if ($db['code'] != 0) return ["code"=>$db['code'],"message"=> $db['message']];
-	                if (!empty($db['data']) && $db['data']['count'] > 0) {
-//	                    return error_show(1004,"供应商公司存在操作账户,请用供应商账户操作");
-	                }
-
-                }
-            }
-        }
-
-        return $next($request);
-    }
-
-
-}

+ 3 - 68
app/admin/middleware/checkToken.php

@@ -2,29 +2,9 @@
 declare (strict_types = 1);
 
 namespace app\admin\middleware;
-use think\facade\Db;
+use app\admin\model\SystemLog;
 class checkToken
 {
-
-	private $post;
-	private $uid=0;
-	private $uname='';
-	private $roleid='0';
-	private $level='0';
-	public $novalidate=[
-		'admin/systemlast',
-		"admin/login",
-		"admin/stats",
-		"admin/departstat",
-		"admin/departEveryDay",
-		"admin/departEveryMonth",
-		"admin/companyEveryMonth",
-		"admin/dzqrd",
-		"admin/companyEvery",
-		"admin/wechat_getinfo",
-		"admin/wechat_getconfig",
-		"admin/totalstat"
-		];
     /**
      * 处理请求
      *
@@ -45,53 +25,8 @@ class checkToken
         	"name"=>'',
         	"addtime"=>date("Y-m-d H:i:s")
         ];
-        Db::name("system_log")->insert($data);
-        if(!in_array($request->pathinfo(),$this->novalidate)){
-        $result = $this->validateToken($request->param());
-	        if($result['code']!=0){
-	            return error_show($result['code'],$result['message']);
-            }
-        }
-		$request->uid=$this->uid;
-		$request->uname=$this->uname;
-		$request->roleid=$this->roleid;
-		$request->level=$this->level;
-
+        SystemLog::create($data);
         return $next($request);
     }
-
-         /**
-		* @return array
-		* @throws \think\db\exception\DataNotFoundException
-		* @throws \think\db\exception\DbException
-		* @throws \think\db\exception\ModelNotFoundException
-		* @throws \think\exception\DbException
-		 */
-     public function validateToken($request){
-            $token = isset($request['token']) ? trim($request['token']) : "";
-            $companyNo = isset($request['relaComNo']) ? trim($request['relaComNo']) : "";
-            if($token==""){
-            	return ["code"=>101,"message"=>"参数token不能为空"];
-            }
-            $effetc = VerifyTokens($token);
-            if(!empty($effetc) && $effetc['code']!=0) {
-            	 return ["code"=>$effetc['code'],"message"=>$effetc['message']];
-            }
-            $this->uid=$effetc['data']['id']??"";
-            $this->uname=$effetc['data']['nickname']??"";
-            $where=[];
-            if($companyNo!=""){
-            	$where=["companyNo"=>$companyNo];
-            }
-            $role = Db::name("user_role")->where(["uid"=>$this->uid,"is_del"=>0])->where($where)->findOrEmpty();
-            if(empty($role)){
-            	 return ["code"=>101,"message"=>"账户已禁用"];
-            }
-            $this->roleid=$role['roleid'];
-            $level =Db::name("role")->where(["id"=>$role['roleid']])->find();
-            if($role['status']==0 || $level['status']==0 ){
-            	$this->level='';
-            }else $this->level = $effetc['data']['level'];//$this->level=$level['level']>1 ?2 :($level['level']??1);
-             return ["code"=>0,"message"=>"验证通过"];
-     }
+    
 }

+ 14 - 0
app/admin/model/CgdInfo.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class CgdInfo extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/CompanyInfo.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class CompanyInfo extends Model
+{
+    //
+}

+ 40 - 0
app/admin/model/Good.php

@@ -0,0 +1,40 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class Good extends Model
+{
+    public static $status=["待采购设置税务类目","待财务设置税务类目","税务类目设置完成"];
+    public static $Tax=['','免税','不征税','零税率'];
+    protected $createTime = "addtime";
+    protected $updateTime = "updatetime";
+    protected $append=["cgd_to_pay",'qrd_to_pay',"companyName","supplierName"];
+    public function GetCgdToPayAttr($v,$row){
+        $isT = CgdInfo::Where(["goodNo"=>$row["spuCode"],"status"=>1,"is_del"=>0])->findOrEmpty()->isEmpty();
+        return  $isT==false;
+    }
+    
+    public function GetQrdToPayAttr($v,$row){
+        $isT = InvoiceGood::Where([['goodNo',"=",$row['spuCode']],['goodNum','>',0]])->findOrEmpty()
+        ->isEmpty();
+         return  $isT==false;
+    }
+    
+     public function GetSupplierNameAttr($v,$row){
+        return SupplierInfo::Where(['code'=>$row['companyNo']])->value('name','');
+    }
+    
+     public function GetCompanyNameAttr($v,$row){
+        return CompanyInfo::Where(['companyNo'=>$row['companyNo']])->value('company_name','');
+    }
+    
+     public function GetExamInfoAttr($v){
+       return $v==""?[]:json_decode($v,true);
+    }
+}

+ 14 - 0
app/admin/model/InvCat.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class InvCat extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/InvoiceGood.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class InvoiceGood extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/QrdInfo.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class QrdInfo extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/SupplierInfo.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class SupplierInfo extends Model
+{
+    //
+}

+ 14 - 0
app/admin/model/SystemLog.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class SystemLog extends Model
+{
+    //
+}

+ 7 - 3
app/command/good.php

@@ -40,9 +40,11 @@ class good extends Command
 
     public function addGood($data){
     	if(empty($data)) return;
+    	$saleAll=[];
+    	
     	foreach ($data as $v){
-			$is=Db::name("good")->where("spuCode",$v['spuCode'])->findOrEmpty();
-			if(empty($is)){
+			$is=\app\admin\model\Good::where("spuCode",$v['spuCode'])->findOrEmpty();
+			if($is->isEmpty()){
 				$array=[
 					"spuCode"=>$v['spuCode'],
 					"good_name"=>$v['good_name'],
@@ -59,14 +61,16 @@ class good extends Command
 					"cat_name"=>$v['cat_id'],
 					"unit_name"=>$v['good_unit'],
 					"isZx"=>$v['isZx'],
+					"exam_info"=>"",
 					"status"=>0,
 					"addtime"=>date("Y-m-d H:i:s"),
 					"updatetime"=>date("Y-m-d H:i:s")
 				];
-				Db::name("good")->insert($array);
+				$saleAll[]=$array;
 				echo "【".date("Y-m-d H:i:s")."】 添加商品{$v['spuCode']}进入类目表\r\n";
 			}
         }
+    	if(empty($saleAll)==false)(new \app\admin\model\Good())->saveAll($saleAll);
     }
 	/**
 	* @throws \think\db\exception\DataNotFoundException

+ 58 - 3
app/common.php

@@ -1,8 +1,6 @@
 <?php
 // 应用公共文件
-use think\facade\Cache;use think\facade\Config;
-use think\facade\Db;
-use think\facade\Filesystem;
+use think\facade\Cache;use think\facade\Config;use think\facade\Db;use think\facade\Filesystem;
 // 应用公共文件
 function app_show($code=0,$message="",$data=[]){
     $result = ['code'=>$code,"message"=>$message,"data"=>$data];
@@ -779,4 +777,61 @@ if(!function_exists("getLadderRate")){
 		}
 		return 0;
 	}
+}
+
+if(!function_exists("CheckTax")){
+	//	1.如果YHZCBS为1, 则ZZSTSGL必须填; 如果YHZCBS为0,ZZSTSGL不填。
+	//	2.如果YHZCBS为1, 且税率为0, 则LSLBS只能根据实际情况选择"1或2"中的一种, 不能选择3, 且ZZSTSGL内容也只能写与1/2对应的"免税/不征税";
+	//	3.如果税率为0,但并不属于优惠政策(即普通的零税率),则YHZCBS填0,LSLBS填3,ZZSTSGL为空;
+	//	4.如果税率不为0, 但属于优惠政策,则YHZCBS填1,LSLBS填空或不填,ZZSTSGL根据实际情况填写;
+	//	5.如果税率不为0, 且不属于优惠政策, 则YHZCBS填0,LSLBS填空或不填,ZZSTSGL不填或空.
+	// 优惠政策下 税率标识只能选择 0非零说率 1免税 2不征税 增值税管理为空"出口零税/免税/不征税"
+	
+//	优惠政策       1        1       0           0
+//	税率          0         13      0             13
+//	零税率标识    1/2        0      3            0
+//	增值税管理  免税/不征税    空值      空值         空值
+	/**
+	* @param $is_discount  优惠政策  0/1
+	* @param $tax          税率
+	* @param $invTag       零税率标识 0非零说率 1免税 2不征税
+	* @param $addTax       增值税管理 出口零税/免税/不征税
+	* @param string $message
+	* @return false
+	*/
+     function CheckTax($is_discount,$tax,$invTag,&$addTax,&$message=""){
+    	// 有优惠政策
+    	
+        if($is_discount==1){
+				if($tax==0){
+					if($invTag==3){
+						$message = "税率标识不能选择零税率";
+						return false;
+					}
+					if($addTax==''){
+						$message = '增值税管理不能为空';
+						return false;
+						
+					}
+					if($addTax!==\app\admin\model\Good::$Tax[$invTag]){
+						$message = '税率标识与增值税管理内容不符';
+						return false;
+					}
+				}
+			}else{
+				// 非优惠政策下 零税率 税率标识只能选择 3 普通零税率  增值税管理为空
+				// 非优惠政策下 非零税率 税率标识只能选择 0 非零税率  增值税管理为空
+				if($tax==0 && $invTag!=3){
+					$message = '税率不为零时税率标识只能选择零税率';
+					return false;
+				}
+				if($tax!=0 && $invTag!=0){
+					$message = '税率为零时税率标识只能选择非零税率';
+					return false;
+				}
+				$addTax='';
+			}
+        
+        return true;
+    }
 }

+ 0 - 1
app/middleware.php

@@ -8,5 +8,4 @@ return [
     // Session初始化
     // \think\middleware\SessionInit::class
     app\admin\middleware\checkToken::class,
-    app\admin\middleware\checkRela::class
 ];