瀏覽代碼

Merge branch 'dev-wgg' of wugg/cxinv into dev

wugg 1 年之前
父節點
當前提交
a299ec4901

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

@@ -176,8 +176,9 @@ class downredinvres extends Command
 	public function checkData($resultChildArr){
 	public function checkData($resultChildArr){
 		foreach ($resultChildArr as $resultChild){
 		foreach ($resultChildArr as $resultChild){
 			$where=['YFPDM'=>$resultChild['YFPDM'] , 'YFPHM'=>$resultChild['YFPHM'] , 'status'=>1];
 			$where=['YFPDM'=>$resultChild['YFPDM'] , 'YFPHM'=>$resultChild['YFPHM'] , 'status'=>1];
-			$row=Db::name('invoice_red')->where($where)->update($resultChild);
-			if ($row) {
+			$row=Db::name('invoice_red')->where($where)->findOrEmpty();
+			if (!empty($row)) {
+				Db::name('invoice_red')->where($where)->update($resultChild);
 				if ($resultChild['status'] == 2) $this->AddRed($resultChild['YFPDM'] , $resultChild['YFPHM']);
 				if ($resultChild['status'] == 2) $this->AddRed($resultChild['YFPDM'] , $resultChild['YFPHM']);
 				if ($resultChild['status'] == 5) $this->updateReturn($row['returnCode'] ,$resultChild['remark']);
 				if ($resultChild['status'] == 5) $this->updateReturn($row['returnCode'] ,$resultChild['remark']);
 			}
 			}

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

@@ -97,7 +97,7 @@ class Base extends BaseController
      public function validateToken($request){
      public function validateToken($request){
             $token = $request['token']?? '';
             $token = $request['token']?? '';
             $companyNo = $request['relaComNo'] ?? '';
             $companyNo = $request['relaComNo'] ?? '';
-            if($token=='') $this->error('参数token不能为空','101');
+            if($token=='') $this->error('参数token不能为空',101);
             $effetc = VerifyTokens($token);
             $effetc = VerifyTokens($token);
             if(!empty($effetc) && $effetc['code']!=0)$this->error($effetc['message'],$effetc['code']);
             if(!empty($effetc) && $effetc['code']!=0)$this->error($effetc['message'],$effetc['code']);
             $this->uid=$effetc['data']['id']??'';
             $this->uid=$effetc['data']['id']??'';
@@ -109,7 +109,7 @@ class Base extends BaseController
             $userrole = \app\admin\model\UserRole::where(['uid'=>$this->uid,'is_del'=>0])->where($where)
             $userrole = \app\admin\model\UserRole::where(['uid'=>$this->uid,'is_del'=>0])->where($where)
             ->findOrEmpty();
             ->findOrEmpty();
             if($userrole->isEmpty()){
             if($userrole->isEmpty()){
-            	 $this->error("账户已禁用",'101');
+            	 $this->error("账户已禁用",101);
             }
             }
             $this->roleid=$userrole->roleid;
             $this->roleid=$userrole->roleid;
             $role =\app\admin\model\Role::where(['id'=>$userrole->roleid])->findOrEmpty();
             $role =\app\admin\model\Role::where(['id'=>$userrole->roleid])->findOrEmpty();

+ 91 - 4
app/admin/controller/Good.php

@@ -3,11 +3,11 @@ declare (strict_types = 1);
 
 
 namespace app\admin\controller;
 namespace app\admin\controller;
 
 
-use think\App;use think\facade\Validate;
+use app\admin\model\GoodChange;use think\App;use think\facade\Validate;
 class Good extends Base
 class Good extends Base
 {
 {
 	protected $model=null;
 	protected $model=null;
-	protected $novalidate=["*"];
+//	protected $novalidate=["*"];
     public function __construct(App $app) {
     public function __construct(App $app) {
     	parent::__construct($app);
     	parent::__construct($app);
     	$this->model=new \app\admin\model\Good();
     	$this->model=new \app\admin\model\Good();
@@ -18,8 +18,8 @@ class Good extends Base
 	 */
 	 */
     public function list(){
     public function list(){
     	$param=$this->request->param(["spuCode"=>"","status"=>"","good_name"=>"",'companyNo'=>'','supplierNo'=>'',
     	$param=$this->request->param(["spuCode"=>"","status"=>"","good_name"=>"",'companyNo'=>'','supplierNo'=>'',
-    	'creater'=>'','isZx'=>'',"cat_diff"=>"","tax_diff"=>"","is_diff"=>"","start"=>"",'end'=>'','page'=>'1',
-    	'size'=>'15'],"post","trim");
+    	'creater'=>'','isZx'=>'','isChange'=>'',"cat_diff"=>"","tax_diff"=>"","is_diff"=>"","start"=>"",'end'=>'',
+    	'page'=>'1','size'=>'15'],"post","trim");
     	$where=[];
     	$where=[];
     	$param["spuCode"]==""?: $where[]=['spuCode','like',"%{$param['spuCode']}%"];
     	$param["spuCode"]==""?: $where[]=['spuCode','like',"%{$param['spuCode']}%"];
     	$param["good_name"]==""?: $where[]=['good_name','like',"%{$param['good_name']}%"];
     	$param["good_name"]==""?: $where[]=['good_name','like',"%{$param['good_name']}%"];
@@ -28,6 +28,7 @@ class Good extends Base
     	$param["creater"]==""?: $where[]=['creater','like',"%{$param['creater']}%"];
     	$param["creater"]==""?: $where[]=['creater','like',"%{$param['creater']}%"];
     	$param["status"]===""?: $where[]=['status','=',$param['status']];
     	$param["status"]===""?: $where[]=['status','=',$param['status']];
     	$param["isZx"]==""?: $where[]=['isZx','=',$param['isZx']];
     	$param["isZx"]==""?: $where[]=['isZx','=',$param['isZx']];
+    	$param["isChange"]===""?: $where[]=['isChange','=',$param['isChange']];
     	$param["is_diff"]==""?: $where[]=['cat_diff|tax_diff','=',2];
     	$param["is_diff"]==""?: $where[]=['cat_diff|tax_diff','=',2];
     	$param["cat_diff"]==""?: $where[]=['cat_diff','=',$param['cat_diff']];
     	$param["cat_diff"]==""?: $where[]=['cat_diff','=',$param['cat_diff']];
     	$param["tax_diff"]==""?: $where[]=['tax_diff','=',$param['tax_diff']];
     	$param["tax_diff"]==""?: $where[]=['tax_diff','=',$param['tax_diff']];
@@ -92,6 +93,11 @@ class Good extends Base
         	    $temp['tax_diff']= $tax==$good->cgd_inv_tax?1:2;
         	    $temp['tax_diff']= $tax==$good->cgd_inv_tax?1:2;
         	    $temp['cat_diff']= $temp['inv_cat_code']==$good->cgd_inv_cat_code?1:2;
         	    $temp['cat_diff']= $temp['inv_cat_code']==$good->cgd_inv_cat_code?1:2;
         	}
         	}
+        	$check = $this->checkChange($good,$temp);
+        	if(!empty($check)){
+        		GoodChange::create($check);
+        		$temp['isChange']=1;
+        	}
         	$examinfo=$good->exam_info;
         	$examinfo=$good->exam_info;
         	$examinfo[]=['apply_name'=>$this->uname,'exam_status'=>$item['status'],"updatetime"=>date("Y-m-d H:i:s")];
         	$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);
         	$temp['exam_info'] = json_encode($examinfo,JSON_UNESCAPED_UNICODE);
@@ -134,4 +140,85 @@ class Good extends Base
     	'类目是否一致','税率是否一致','创建时间'];
     	'类目是否一致','税率是否一致','创建时间'];
     	excelExport("商品税率异常记录", $header, $list);
     	excelExport("商品税率异常记录", $header, $list);
     }
     }
+    /**
+	* @param $good
+	* @param $check
+	 * @return array
+	 */
+    private function checkChange($good,$check){
+    	$temp=[];
+        if($check['status']==1){
+        	$before=[];
+        	$after=[];
+        	    if($good->cgd_inv_cat_code!=""&&$check['cgd_inv_cat_code']!=$good->cgd_inv_cat_code){
+        	        $before['inv_cat_code']  = $good->cgd_inv_cat_code;
+        	        $after['inv_cat_code']  = $check['cgd_inv_cat_code'];
+        	    }
+        	     if($good->cgd_inv_cat_name!=''&&$check['cgd_inv_cat_name']!=$good->cgd_inv_cat_name){
+        	    	$before['inv_cat_name']  = $good->cgd_inv_cat_name;
+        	    	$after['inv_cat_name']  = $check['cgd_inv_cat_name'];
+        	    }
+        	      if($good->cgd_inv_good_name!=''&&$check['cgd_inv_good_name']!=$good->cgd_inv_good_name){
+        	    	$before['inv_good_name']  = $good->cgd_inv_good_name;
+        	    	$after['inv_good_name']  = $check['cgd_inv_good_name'];
+        	    }
+        	    if($good->cgd_inv_tax!=''){
+        	       	$cgd_inv_tax = bcdiv(str_replace('%', '', $good->cgd_inv_tax), '100', 2);
+        	       	if($check['cgd_inv_tax']!=$cgd_inv_tax){
+	                    $before['inv_tax']  = $cgd_inv_tax;
+	                    $after['inv_tax']  = $check['cgd_inv_tax'];
+        	        }
+        	    }
+        	    
+        	    if(!empty($before))$temp['before'] = json_encode($before,JSON_UNESCAPED_UNICODE);
+        	    if(!empty($after))$temp['after'] = json_encode($after,JSON_UNESCAPED_UNICODE);
+        }
+        
+        if($check['status']==2){
+        	$before=[];
+        	$after=[];
+        	    if($good->inv_cat_code!=''&&$check['inv_cat_code']!=$good->inv_cat_code){
+        	        $before['inv_cat_code']  = $good->inv_cat_code;
+        	        $after['inv_cat_code']  = $check['inv_cat_code'];
+        	    }
+        	    if($good->inv_cat_name!=''&&$check['inv_cat_name']!=$good->inv_cat_name){
+        	    	$before['inv_cat_name']  = $good->inv_cat_name;
+        	    	$after['inv_cat_name']  = $check['inv_cat_name'];
+        	    }
+        	    if($good->inv_good_name!=''&&$check['inv_good_name']!=$good->inv_good_name){
+        	    	$before['inv_good_name']  = $good->inv_good_name;
+        	    	$after['inv_good_name']  = $check['inv_good_name'];
+        	    }
+        	    if($good->inv_tax!=''){
+        	    	$inv_tax = bcdiv(str_replace('%', '', $good->inv_tax), '100', 2);
+        	    	if($check['inv_tax']!=$inv_tax){
+                        $before['inv_tax']  = $inv_tax;
+                        $after['inv_tax']  = $check['inv_tax'];
+        	    	}
+        	    }
+        	    
+        	    if($good->status==2&&$check['inv_tag']!=$good->inv_tag){
+         	    	$before['inv_tag']  = $good->inv_tag;
+        	    	$after['inv_tag']  = $check['inv_tag'];
+        	    }
+				if($good->status==2&&$check['is_discount']!=$good->is_discount){
+         	    	$before['is_discount']  = $good->is_discount;
+        	    	$after['is_discount']  = $check['is_discount'];
+        	    }
+				if($good->status==2&&$check['addTax']!=$good->addTax){
+         	    	$before['addTax']  = $good->addTax;
+        	    	$after['addTax']  = $check['addTax'];
+        	    }
+        	    if(!empty($before))$temp['before'] = json_encode($before,JSON_UNESCAPED_UNICODE);
+        	    if(!empty($after))$temp['after'] = json_encode($after,JSON_UNESCAPED_UNICODE);
+        }
+        if(!empty($temp)){
+        	$temp['spuCode'] = $good->spuCode;
+        	$temp['good_name'] = $good->good_name;
+        	$temp['apply_id'] = $this->uid;
+        	$temp['apply_name'] = $this->uname;
+        	$temp['exam_status'] =$check['status'];
+        }
+        return $temp;
+    }
 }
 }

+ 71 - 0
app/admin/controller/GoodChange.php

@@ -0,0 +1,71 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\controller;
+
+use think\App;
+use think\facade\Validate;
+
+class GoodChange extends Base
+{
+	protected $model=null;
+    public function __construct(App $app) {
+    	parent::__construct($app);
+    	$this->model=new \app\admin\model\GoodChange();
+    }
+    //列表详情
+
+    public function list(){
+        $params = $this->request->param(['spuCode'=>'','page' => 1,'size' => 15],'post','trim');
+        $where = [];
+
+        if($params['spuCode'] !== '') {
+            $where[] = ['spuCode','like',"%{$params['spuCode']}%"];
+        }
+
+        $list = $this->model
+                    ->where($where)->json(['before','after'],true)
+                    ->order('id desc')
+                    ->select();
+
+        $result = [];
+        foreach ($list as $item){
+        	
+            $keys = array_keys($item["before"]);
+            foreach ($keys as $key){
+            	$temp=[];
+                $temp['field'] = \app\admin\model\GoodChange::$mapField[$key] ?? "";
+                $temp['before'] = $item['before'][$key] ?? "";
+                $temp['after'] = $item['after'][$key] ?? "";
+                $temp['apply_name'] = $item['apply_name'];
+                $temp['addtime'] = $item['addtime'];
+                $result[] = $temp;
+            }
+           
+            
+        }
+
+        $this->success('获取成功', $result);
+    }
+
+	//详情
+    public function info(){
+        $params=$this->request->param(['id'=>''],'post','trim');
+        $valid=Validate::rule(['id|修改记录ID'=>'require']);
+
+        if($valid->check($params)==false){
+            $this->error($valid->getError());
+        }
+
+        $changeInfo = $this->model
+                      ->json(['before','after'])
+                      ->where(["id"=>$params['id']])
+                      ->findOrEmpty();
+
+        if($changeInfo->isEmpty()){
+            $this->error("修改记录不存在");
+        }
+
+        $this->success("获取成功",$changeInfo);
+    }
+}

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

@@ -1245,10 +1245,12 @@ class Payment extends Base
             //$da_insert 批量新增的数据,$payNo_hpNo对账编码=>回票编码
             //$da_insert 批量新增的数据,$payNo_hpNo对账编码=>回票编码
             $da_insert = $payNo_hpNo = [];
             $da_insert = $payNo_hpNo = [];
             $date = date('Y-m-d H:i:s');
             $date = date('Y-m-d H:i:s');
+            $unique=[];
             foreach ($param['list'] as $item) {
             foreach ($param['list'] as $item) {
 
 
                 if (!$val->check($item)) throw new Exception($val->getError());
                 if (!$val->check($item)) throw new Exception($val->getError());
-
+				if(in_array($item['invoiceNumber'],$unique))throw new Exception("{$item['invoiceNumber']} 发票重复提交");
+                $unique[]=$item['invoiceNumber'];
                 if (!isset($payinfo[$item['payNo']])) throw new Exception('对账单数据未找到');
                 if (!isset($payinfo[$item['payNo']])) throw new Exception('对账单数据未找到');
                 if ($payinfo[$item['payNo']]['status'] != 2) throw new Exception('对账单数据未完成审核');
                 if ($payinfo[$item['payNo']]['status'] != 2) throw new Exception('对账单数据未完成审核');
 				$invamount=0;
 				$invamount=0;
@@ -1683,8 +1685,7 @@ class Payment extends Base
         }
         }
     }
     }
 	/**
 	/**
-	* @return \think\
- * response\Json|void
+	* @return \think\|\think\response\Json|void
 	*/
 	*/
     public function  ticketInfo(){
     public function  ticketInfo(){
 		$num =isset($this->post['number'])&&$this->post['number']!=''?trim($this->post['number']):"";
 		$num =isset($this->post['number'])&&$this->post['number']!=''?trim($this->post['number']):"";

+ 25 - 0
app/admin/model/GoodChange.php

@@ -0,0 +1,25 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class GoodChange extends Model
+{
+    public static $mapField = [
+        'inv_good_name'=> '商品名称',
+        'inv_cat_name' => '商品类目',
+        'inv_tax' => '商品税率',
+        'is_discount' => '是否有优惠政策',
+        'addTax' => '增值税管理内容',
+        'inv_tag' => '税率标识'
+    ];
+
+    public function Good(){
+    	return $this->belongsTo(Good::class,"spuCode","spuCode");
+    }
+}

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

@@ -269,5 +269,7 @@ route::rule("departtipsadd","admin/DepartTips/departcreate");//网络部录单
 route::rule("wechat_getinfo","admin/WeChat/getinfo");//微信授权获取用户信息
 route::rule("wechat_getinfo","admin/WeChat/getinfo");//微信授权获取用户信息
 route::rule("wechat_getconfig","admin/WeChat/getConfig");//微信获取页面jssdk配置
 route::rule("wechat_getconfig","admin/WeChat/getConfig");//微信获取页面jssdk配置
 
 
+route::rule("goodChangeList","admin/GoodChange/list");
+route::rule("goodChangeInfo","admin/GoodChange/info");