wugg 7 місяців тому
батько
коміт
2b9705a46c

+ 23 - 6
app/admin/controller/Consult.php

@@ -774,13 +774,19 @@ class Consult extends Base
 			 $spucode=makeNo('SSU');
 		}
 		$tax_id = isset($this->post['tax_id'])&&$this->post['tax_id']!==''? intval($this->post['tax_id']):'0';
+		$cgd_tax_id = isset($this->post['cgd_tax_id'])&&$this->post['cgd_tax_id']!==''? intval($this->post['cgd_tax_id']):'0';
+		$cgd_tax = isset($this->post['cgd_tax'])&&$this->post['cgd_tax']!==''? trim($this->post['cgd_tax']):'';
         $open_type= isset($this->post['open_type'])&&$this->post['open_type']!==''? intval($this->post['open_type']):1;
         $inv_good_name = isset($this->post['inv_good_name'])&&$this->post['inv_good_name']!==''? trim($this->post['inv_good_name']):'';
         if($open_type=='') return error_show(1004,'开票商品类型不能为空');
-            if($open_type==1){
-                if($tax_id=='') return error_show(1004,'商品税目id不能为空');
-                if($inv_good_name=='') return error_show(1004,'开票商品名称不能为空');
+        if($open_type==1){
+            if($tax_id=='') return error_show(1004,'商品税目id不能为空');
+            if($inv_good_name=='') return error_show(1004,'开票商品名称不能为空');
+            if($cgd_supplier_code!=""){
+                if($cgd_tax_id==0) return error_show(1004,'源头供应商开票税目不能为空');
+                if($cgd_tax==='') return error_show(1004,'源头供应商开票税率不能为空');
             }
+        }
         //计算毛利率
         $budget = get_budget($zxinfo['cat_id'], $zx['companyNo'], $zx['platform_code']);
 		if($budget===false) $this->error('未找到业务公司有关的平台分类毛利信息');
@@ -909,6 +915,8 @@ class Consult extends Base
 	        "open_type"=>$open_type,
 	        "inv_good_name"=>$inv_good_name,//采购商品名称
 	        "tax_id"=>$tax_id,//税目id
+	        "cgd_tax"=>$cgd_tax,//税目
+	        "cgd_tax_id"=>$cgd_tax_id
         ];
         Db::startTrans();
         try{
@@ -1082,9 +1090,10 @@ class Consult extends Base
         $info['child'] =[];
         if($info['is_combind']==1){
             $info['child'] =ConsultTemp::where(['bidNo'=>$bidNo])->select()->each(function(&$item){
-                $tax = TaxCategory::where(['id'=>[$item['tax_id'],$item['out_tax_id']]])->column('short_name,cat_name,cat_code,merge_code','id');
+                $tax = TaxCategory::where(['id'=>[$item['tax_id'],$item['out_tax_id'],$item['cgd_tax_id']]])->column('short_name,cat_name,cat_code,merge_code','id');
                 $item['in_info'] = $tax[$item['tax_id']]??[];
                 $item['out_info'] = $tax[$item['out_tax_id']]??[];
+                $item['cgd_info'] = $tax[$item['cgd_tax_id']]??[];
             });
         }
         //添加商品创建人字段
@@ -1164,7 +1173,6 @@ class Consult extends Base
 	        $cgd_apply_id =  isset($this->post['cgd_apply_id'])&&$this->post['cgd_apply_id']!=''? trim($this->post['cgd_apply_id']):0;
 	        $cgd_apply_name =  isset($this->post['cgd_apply_name'])&&$this->post['cgd_apply_name']!=''? trim($this->post['cgd_apply_name']):'';
 	        $supplier_origin_price =  isset($this->post['supplier_origin_price'])&&$this->post['supplier_origin_price']!=''? floatval($this->post['supplier_origin_price']):0;
-	        $cgd_supplier_name='';
                 $user= \app\admin\common\User::getIns();
         $supplier =$user->handle("getCodeAndName",["code"=>[$supplierNo,$cgd_supplier_code]]);
 
@@ -1244,10 +1252,16 @@ class Consult extends Base
         $tax_id = isset($this->post['tax_id'])&&$this->post['tax_id']!==''? intval($this->post['tax_id']):'';
         $open_type= isset($this->post['open_type'])&&$this->post['open_type']!==''? intval($this->post['open_type']):'';
         $inv_good_name = isset($this->post['inv_good_name'])&&$this->post['inv_good_name']!==''? trim($this->post['inv_good_name']):'';
+        $cgd_tax_id = isset($this->post['cgd_tax_id'])&&$this->post['cgd_tax_id']!==''? intval($this->post['cgd_tax_id']):'0';
+		$cgd_tax = isset($this->post['cgd_tax'])&&$this->post['cgd_tax']!==''? trim($this->post['cgd_tax']):'';
         if($open_type=='') return error_show(1004,'开票商品类型不能为空');
         if($open_type==1){
             if($tax_id=='') return error_show(1004,'商品税目id不能为空');
             if($inv_good_name=='') return error_show(1004,'开票商品名称不能为空');
+            if($cgd_supplier_code!=''){
+                if($cgd_tax_id==0) return error_show(1004,'源头供应商开票税目不能为空');
+                if($cgd_tax==='') return error_show(1004,'源头供应商开票税率不能为空');
+            }
         }
         Db::startTrans();
         try{
@@ -1302,6 +1316,8 @@ class Consult extends Base
 		        'open_type'=>$open_type,
                 'inv_good_name'=>$inv_good_name,//采购商品名称
                 'tax_id'=>$tax_id,//税目id
+                'cgd_tax'=>$cgd_tax,//税目
+	            'cgd_tax_id'=>$cgd_tax_id
             ];
             $insert= Db::name("consult_bids")->where($bidinfo)->save($data);
             if($insert){
@@ -2070,9 +2086,10 @@ class Consult extends Base
                 list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$value['origin_place']);
             }
             $value['origin_addr']=GetAddr(json_encode($place));
-           $tax = TaxCategory::where(['id'=>[$value['tax_id'],$value['out_tax_id']]])->column('short_name,cat_name,cat_code,merge_code','id');
+           $tax = TaxCategory::where(['id'=>[$value['tax_id'],$value['out_tax_id'],["cgd_tax_id"]]])->column('short_name,cat_name,cat_code,merge_code','id');
             $value['in_info'] = $tax[$value['tax_id']]??[];
             $value['out_info'] = $tax[$value['out_tax_id']]??[];
+            $value['cgd_info'] = $tax[$value['cgd_tax_id']]??[];
 		$good_info = Db::name('good_basic')
             ->field('id,createrid,creater')
             ->where('is_del',0)

+ 18 - 8
app/admin/controller/Goodup.php

@@ -580,8 +580,7 @@ class Goodup extends Base
         if($is_stock===""){
             return error_show(1004,"参数is_stock不能为空");
         }
-        // $stock_moq=0 ;//库存品备库起订量; 如果是0 表示无限制;
-         $stock_moq = isset($this->post['stock_moq'])&&$this->post['stock_moq']!==""? intval($this->post['stock_moq']):"0";
+        $stock_moq = isset($this->post['stock_moq'])&&$this->post['stock_moq']!==""? intval($this->post['stock_moq']):"0";
         if($is_stock==1 && $stock_moq ==0){
             return error_show(1004,"库存品备库起订量不能为零");
         }
@@ -616,7 +615,8 @@ class Goodup extends Base
             return error_show(1004,"参数market_price不能为空");
         }
         $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"0";
-        
+        $cgd_tax_id = isset($this->post['cgd_tax_id'])&&$this->post['cgd_tax_id']!==''? intval($this->post['cgd_tax_id']):'0';
+        $cgd_tax = isset($this->post['cgd_tax'])&&$this->post['cgd_tax']!==''? trim($this->post['cgd_tax']):'';
         $speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
         $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])? $this->post['good_ladder']:"";
         $is_support_barter = isset($this->post['is_support_barter']) && $this->post['is_support_barter'] !== "" ? intval($this->post['is_support_barter']) : 1;
@@ -628,6 +628,10 @@ class Goodup extends Base
 			if($open_type==1){
 				if($tax_id=='') return error_show(1004,'商品税目id不能为空');
 				if($inv_good_name=='') return error_show(1004,'开票商品名称不能为空');
+				if($cgd_supplier_code!=''){
+                    if($cgd_tax_id==0) return error_show(1004,'源头供应商开票税目不能为空');
+                    if($cgd_tax==='') return error_show(1004,'源头供应商开票税率不能为空');
+                }
 			}
         $createrid= $this->uid;
         $creater= $this->uname;
@@ -805,6 +809,8 @@ class Goodup extends Base
 				        "companyNo"=>$company_id,
 				        'tax_id'=>$tax_id,
 				        'inv_good_name'=>$inv_good_name,
+				        "cgd_tax_id"=>$cgd_tax_id,
+				        "cgd_tax"=>$cgd_tax,
 				        'tax'=>$tax,
 				        "creater"=>$creater,
 				        "createrid"=>$createrid,
@@ -2358,10 +2364,6 @@ class Goodup extends Base
         if($is_exclusive===''){
             return error_show(1004,"参数is_exclusive不能为空");
         }
-//        $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
-//        if($customized===''){
-//            return error_show(1004,"参数customized不能为空");
-//        }
         $tax = isset($this->post['tax'])&&$this->post['tax']!==""? intval($this->post['tax']):"";
         if($tax===''){
             return error_show(1004,"参数tax不能为空");
@@ -2519,10 +2521,16 @@ class Goodup extends Base
 		$tax_id = isset($this->post['tax_id'])&&$this->post['tax_id']!==''? intval($this->post['tax_id']):'';
         $open_type= isset($this->post['open_type'])&&$this->post['open_type']!==''? intval($this->post['open_type']):'';
         $inv_good_name = isset($this->post['inv_good_name'])&&$this->post['inv_good_name']!==''? trim($this->post['inv_good_name']):'';
+        $cgd_tax_id = isset($this->post['cgd_tax_id'])&&$this->post['cgd_tax_id']!==''? intval($this->post['cgd_tax_id']):'0';
+        $cgd_tax = isset($this->post['cgd_tax'])&&$this->post['cgd_tax']!==''? trim($this->post['cgd_tax']):'';
         if($open_type=='') return error_show(1004,'开票商品类型不能为空');
             if($open_type==1){
                 if($tax_id=='') return error_show(1004,'商品税目id不能为空');
                 if($inv_good_name=='') return error_show(1004,'开票商品名称不能为空');
+                if($cgd_supplier_code!=''){
+                    if($cgd_tax_id==0) return error_show(1004,'源头供应商开票税目不能为空');
+                    if($cgd_tax==='') return error_show(1004,'源头供应商开票税率不能为空');
+                }
             }
 		 if($isCombind==1){
 			if(empty($combindList)) return error_show(1004,'组合商品子商品信息不能为空');
@@ -2702,11 +2710,13 @@ class Goodup extends Base
                     $taxInfo->open_type = $open_type;
                     $taxInfo->tax_id = $tax_id;
                     $taxInfo->inv_good_name = $inv_good_name;
+				    $taxInfo->cgd_tax_id = $cgd_tax_id;
+                    $taxInfo->cgd_tax = $cgd_tax;
                     $taxInfo->tax = $tax;
                     $taxInfo->creater = $this->uname;
                     $taxInfo->createrid =$this->uid;
                     $taxInfo->save();
-                            }
+                }
                 Db::commit();
                 return app_show(0,"更新成功");
             }else{

+ 6 - 7
app/admin/controller/Sale.php

@@ -4749,11 +4749,10 @@ class Sale extends Base
             $price = Db::name("gold_price1")->where(["type" => $order['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->find();
 
         }
-        $order['tax_info']=GoodTax::with(['Tax','OutTax'])->where(['spuCode'=>$orderCode])->findOrEmpty();
+        $order['tax_info']=GoodTax::with(['Tax','OutTax',"CgdTax"])->where(['spuCode'=>$orderCode])->findOrEmpty();
 		$depart = get_company_name_by_uid($order['order_createrid']);
         $userCommon = \app\admin\common\User::getIns();
         $supplier = $userCommon->handle('sInfo',['code'=>$order['supplierNo']]);
-//        $supplier = Db::name("supplier")->where(["code" => $order['supplierNo']])->find();
         $order['supplier_name'] = isset($supplier['data']['name']) ? $supplier['data']['name'] : "";
         $order['cgder'] = isset($supplier['data']['person']) ? $supplier['data']['person'] : "";
         $order['cgderid'] = isset($supplier['data']['personid']) ? $supplier['data']['personid'] : "";
@@ -4763,10 +4762,8 @@ class Sale extends Base
         $value['is_basic']= Db::name('good_basic')->where(['spuCode'=>$order['spuCode']])->value("status",null);
         $palt = Db::name("platform")->where(["id" => $order['platform_id']])->find();
         $order['platform_name'] = isset($palt['platform_name']) ? $palt['platform_name'] : "";
-
         $names = $userCommon->handle('getCodeAndName',['code'=>$order['companyNo']]);
-//        $company = Db::name("business")->where(["companyNo" => $order['companyNo']])->find();
-        $order['company'] = $names['data'][$order['companyNo']]??'';//isset($company['company']) ? $company['company'] : "";
+        $order['company'] = $names['data'][$order['companyNo']]??'';
         $order["gold_price"] = isset($price['price']) ? $price['price'] : 0;
         $order["noble_weight"] = isset($order['weight']) ? $order['weight'] : 0;
         return app_show(0, "获取成功", $order);
@@ -4810,15 +4807,17 @@ class Sale extends Base
         $order['supplier_name'] = $supplier_temp['data'][$order['supplierNo']]??"";
         $order["gold_price"] = isset($price['price']) ? $price['price'] : 0;
         $order["noble_weight"] = isset($order['weight']) ? $order['weight'] : 0;
-        $tax = TaxCategory::where(['id'=>[$order['tax_id'],$order['out_tax_id']]])->column('short_name,cat_name,cat_code,merge_code','id');
+        $tax = TaxCategory::where(['id'=>[$order['tax_id'],$order['out_tax_id'],$order['cgd_tax_id']]])->column('short_name,cat_name,cat_code,merge_code','id');
         $order['in_info'] = $tax[$order['tax_id']]??[];
         $order['out_info'] = $tax[$order['out_tax_id']]??[];
+        $order['cgd_info'] = $tax[$order['cgd_tax_id']]??[];
         $order['child'] =[];
         if($order['is_combind']==1){
             $order['child'] =ConsultTemp::where(['bidNo'=>$order['bidNo']])->select()->each(function(&$item){
-                $tax = TaxCategory::where(['id'=>[$item['tax_id'],$item['out_tax_id']]])->column('short_name,cat_name,cat_code,merge_code','id');
+                $tax = TaxCategory::where(['id'=>[$item['tax_id'],$item['out_tax_id'],$item['cgd_tax_id']]])->column('short_name,cat_name,cat_code,merge_code','id');
                 $item['in_info'] = $tax[$item['tax_id']]??[];
                 $item['out_info'] = $tax[$item['out_tax_id']]??[];
+                $item['cgd_info'] = $tax[$item['cgd_tax_id']]??[];
             });
         }
         $good_info = Db::name('good_basic')

+ 37 - 18
app/admin/model/GoodTax.php

@@ -5,7 +5,7 @@ namespace app\admin\model;
 
 use app\model\TaxCategory;
 use app\model\TaxRelation;use think\Model;
-use think\model\concern\SoftDelete;
+use think\model\concern\SoftDelete;use function Symfony\Component\String\b;
 
 /**
  * @mixin \think\Model
@@ -26,32 +26,51 @@ class GoodTax extends Model
         return $this->belongsTo(TaxCategory::class,'out_tax_id','id')
         ->bind(["out_tax_name"=>'cat_name',"out_tax_code"=>'cat_code',"out_tax_short"=>'short_name',"out_tax_merge"=>'merge_code']);
     }
+    public function CgdTax(){
+        return $this->belongsTo(TaxCategory::class,'cgd_tax_id','id')
+        ->bind(['cgd_tax_name'=>'cat_name','cgd_tax_code'=>'cat_code','cgd_tax_short'=>'short_name','cgd_tax_merge'=>'merge_code']);
+    }
     /**
     * @param $spuCode
     * @param int $type 1 进项票 2 销项票
      * @return array
      */
     public static function getInfobySpuCode($spuCode,$type=1){
-        $item = (new GoodTax)->with(['Tax',"OutTax"])->where(['spuCode'=>$spuCode])->findOrEmpty();
+        $item = (new GoodTax)->with(['Tax',"OutTax","CgdTax"])->where(['spuCode'=>$spuCode])->findOrEmpty();
         if($item->isEmpty()) return [];
         $temp=[];
-        if($type==1){
-             $temp['spuCode']=$item->spuCode;
-             $temp['cat_code']=$item->in_tax_code;
-             $temp['cat_name']=$item->in_tax_name;
-             $temp['short_name']=$item->in_tax_short;
-             $temp['merge_code']=$item->in_tax_merge;
-             $temp['tax']= str_replace("%","",$item->tax);
-             $temp['inv_good_name']=$item->inv_good_name;
-        }else{
-             $temp['spuCode']=$item->spuCode;
-             $temp['cat_code']=$item->out_tax_code??"";
-             $temp['cat_name']=$item->out_tax_name??"";
-             $temp['short_name']=$item->out_tax_short??"";
-             $temp['merge_code']=$item->out_tax_merge;
-             $temp['tax']= str_replace('%','',$item->out_tax);
-             $temp['inv_good_name']=$item->inv_good_name;
+        switch ($type){
+            case 1:
+                 $temp['spuCode']=$item->spuCode;
+                 $temp['cat_code']=$item->in_tax_code;
+                 $temp['cat_name']=$item->in_tax_name;
+                 $temp['short_name']=$item->in_tax_short;
+                 $temp['merge_code']=$item->in_tax_merge;
+                 $temp['tax']= str_replace('%','',$item->tax);
+                 $temp['inv_good_name']=$item->inv_good_name;
+              break;
+            case 2:
+                 $temp['spuCode']=$item->spuCode;
+                 $temp['cat_code']=$item->out_tax_code??'';
+                 $temp['cat_name']=$item->out_tax_name??'';
+                 $temp['short_name']=$item->out_tax_short??'';
+                 $temp['merge_code']=$item->out_tax_merge;
+                 $temp['tax']= str_replace('%','',$item->out_tax);
+                 $temp['inv_good_name']=$item->inv_good_name;
+                 break;
+            case 3:
+                 $temp['spuCode']=$item->spuCode;
+                 $temp['cat_code']=$item->cgd_tax_code??'';
+                 $temp['cat_name']=$item->cgd_tax_name??'';
+                 $temp['short_name']=$item->cgd_tax_short??'';
+                 $temp['merge_code']=$item->cgd_tax_merge;
+                 $temp['tax']= str_replace('%','',$item->cgd_tax);
+                 $temp['inv_good_name']=$item->inv_good_name;
+                 break;
+            default:
+                break;
         }
+
         return $temp;
     }
 }