Jelajahi Sumber

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

wugg 4 bulan lalu
induk
melakukan
a1a5fd79ce

+ 5 - 4
app/admin/command/CheckTicket.php

@@ -27,6 +27,7 @@ class CheckTicket extends Command
     {
         $this->dateTime = date("Y-m-d H:i:s");
         if(Cache::get('checkTicketP')==1 || date("H")<12)return;
+         Cache::set('checkTicketP',1,1800);
         $this->output=$output;
         $ticket = $this->getTicket();
         while ($ticket->valid()) {
@@ -78,7 +79,7 @@ class CheckTicket extends Command
                 $this->changeFiled($data,$info);
             }elseif (in_array($result['data']['cyjg'],['0002','1014'])){
                 $this->lastUpdate($info['invNo']);
-            }else $this->faild($invoice['id'],$result['data']['cyjgxx']);
+            }else $this->faild($info['invNo'],$result['data']['cyjgxx']);
         }else $this->faild($info['invNo'],'验票失败');
        }catch (\Exception $e){
             Db::rollback();
@@ -110,10 +111,10 @@ class CheckTicket extends Command
             'updatetime'=>$this->dateTime,
             ]);
         }
-        $info=InvoicePool::where(['invNo'=>$info['invNo']])->save(["status"=>4,"updatetime"=>$this->dateTime]);
-        if($info==false) throw new \Exception("更新发票状态失败");
+        $wq=InvoicePool::where(['invNo'=>$info['invNo']])->save(["status"=>4,"updatetime"=>$this->dateTime]);
+        if($wq==false) throw new \Exception("更新发票状态失败");
         \app\admin\model\Assoc::subOrder($info['invNo']);
-          if($info->is_comon==1)event('comonOrder',['invNo'=>$info['invNo'],'type'=>'inv']);
+          if($info['is_comon']==1)event('comonOrder',['invNo'=>$info['invNo'],'type'=>'inv']);
     }
     protected function itemFiled($detail){
 

+ 63 - 44
app/admin/controller/Export.php

@@ -223,9 +223,11 @@ class Export extends Base
     //资金认领导出
     public function orderPayExport()
     {
-        $param = $this->request->only(['start' => '', 'end' => '','create_start' => '', 'create_end' => '', 'name' => '', 'bank' => '', 'status' => '', 'tradNo' => '', 'company' => '', 'userd_lower' => '', 'used_upper' => ''], 'post', 'trim');
-        $where = [['a.is_del', '=', 0],['b.is_del', '=', 0],['d.is_del', '=', 0],['d.is_del', '=', 0],["c.type","=",2],["c.status","in",[1,2]]];
-        if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['a.trade_time', 'between', [$param['start'] . ' 00:00:00', $param['end'] . ' 23:59:59']];
+        $param = $this->request->only(['start' => '', 'end' => '','create_start' => '', 'create_end' => '', 'name' => '',
+        'bank' => '', 'status' => '', 'tradNo' => '', 'company' => '', 'userd_lower' => '', 'used_upper' => '',"logNo"=>"",
+        "orderCode"=>"","cxCode"=>"","pcCode"=>"","platform_type"=>"","relaNo"=>""], 'post', 'trim');
+        $where = [["b.is_del","=",0]];
+        if (($param['start'] != '') && ($param['end'] != '')) $where[] = ['b.addtime', 'between', [$param['start'] . ' 00:00:00', $param['end'] . ' 23:59:59']];
         if (($param['create_start'] != '') && ($param['create_end'] != '')) $where[] = ['b.addtime', 'between', [$param['create_start'] . ' 00:00:00', $param['create_end'] . ' 23:59:59']];
         if ($param['name'] != '') $where[] = ['a.trade_out', 'like', '%' . $param['name'] . '%'];
         if ($param['bank'] != '') $where[] = ['a.trade_bank', 'like', '%' . $param['bank'] . '%'];
@@ -234,55 +236,72 @@ class Export extends Base
         if ($param['company'] != '') $where[] = ['b.companyNo', 'like', '%' . $param['company'] . '%'];
         if ($param['userd_lower'] != '') $where[] = ['a.used_fee', '>=', $param['userd_lower']];
         if ($param['used_upper'] != '') $where[] = ['a.used_fee', '<=', $param['used_upper']];
+        if($param["logNo"]!="") $where[] = ['b.logNo', 'like', '%'.$param['logNo'].'%'];
+        if($param["orderCode"]!="") $where[] = ['c.orderCode', 'like', '%'.$param['orderCode'].'%'];
+        if($param["cxCode"]!="") $where[] = ['d.cxCode', 'like', '%'.$param['cxCode'].'%'];
+        if($param["pcCode"]!="") $where[] = ['a.pcCode', 'like', '%'.$param['pcCode'].'%'];
+        if($param["platform_type"]!="") $where[] = ['d.platform_type', '=', $param['platform_type']];
 
         $status = [1 => '未认领', 2 => '部分认领', 3 => '全部认领'];//状态
         $b_status = [1 => '待审批', 2 => '审批通过', 3 => '审批驳回', 4 => '退款', 5 => '解除认领'];//认领审批状态
-
-        $list = Db::name('trade')
-            ->alias('a')
-            ->leftJoin("trade_lib e","a.tradNo=e.tradNo")
-            ->field('a.companyNo 收款方公司编码,
-            a.pcCode 资金批次号 ,
-            a.trade_in 收款单位名称,
-            a.trade_account 付款银行单位账号,
-            a.trade_out 付款银行单位名称,
-            a.trade_used 付款备注,
-            a.trade_time 交易时间,
-            a.tradNo 资金编号,
-            a.status 状态,
-            a.total_fee 收入金额,
-            a.balance 未认领金额,
-            a.used_fee 已认领金额,
-            b.total_fee 资金认领金额,
-            b.logNo 资金认领编号,
-            d.companyNo 业务公司编号,
-            d.companyName 业务公司名称,
-            b.customerNo 认领企业,
-            if(a.trade_type=0,"自营","平台") as 资金回款类型, 
-            e.palt_po  平台采购PO,
-            b.relaNo 关联资金认领编号,
-            if(b.tag_type=0,"手动创建","自动创建") as 操作类型,
-            if(d.is_comon=1,"通用订单","自营订单") as 订单业务类型,
-            c.orderCode 订单编号,
-            d.cxCode 销售主单号,
-            d.poCode 平台编号,
-            d.goodNo  商品SKU,
-            d.goodName 产品名称,
-            d.ownerName 资金创建人,
-            c.apply_name 认领创建人,
-            b.status 认领审批状态,
-            b.remark 驳回原因')
-            ->leftJoin('trade_pool b', 'b.tradNo=a.tradNo')
-            ->leftJoin('assoc c', 'c.viceCode=b.logNo')
-            ->leftJoin('qrd_info d', 'd.sequenceNo=c.orderCode')
-            ->where($where)
-            ->order('a.trade_time desc')
-           ->cursor();
+        $list = Db::name('trade')->alias('a')
+                ->leftJoin('trade_pool b', 'a.tradNo=b.tradNo and a.is_del=0')
+                ->leftjoin('trade_lib e', 'b.tradNo=e.tradNo')
+                ->leftJoin('assoc c', 'b.logNo=c.viceCode AND c.type = 2 and c.is_del=0')
+                ->leftJoin('qrd_info d', 'c.orderCode=d.sequenceNo and d.is_del=0')
+                ->field('a.companyNo 收款方公司编码,
+                       a.pcCode 资金批次号 ,
+                       a.trade_in 收款单位名称,
+                       a.trade_account 付款银行单位账号,
+                       a.trade_out 付款银行单位名称,
+                       a.trade_used 交易用途,
+                       a.trade_time 交易时间,
+                       a.tradNo 资金编号,
+                       a.status 状态,
+                       a.total_fee 收入金额,
+                       a.balance 未认领金额,
+                       a.used_fee 已认领金额,
+                       b.total_fee 资金认领金额,
+                       b.logNo 资金认领编号,
+                       d.companyNo 业务公司编号,
+                       d.companyName 业务公司名称,
+                       b.customerNo 认领企业,
+                       if(a.trade_type=0,"自营","平台") as 资金回款类型, 
+                       b.relaNo 关联资金认领编号,
+                       if(b.tag_type=0,"手动创建","自动创建") as 操作类型,
+                       if(d.is_comon=1,"通用订单","自营订单") as 订单业务类型,
+                       c.orderCode 订单编号,
+                       d.cxCode 销售主单号,
+                       d.platform_type 平台类型,
+                       d.platName 平台名称,
+                       d.poCode 平台订单编号,
+                       a.poCode 客户PO,
+                       d.goodNo  商品SKU,
+                       e.skuCode 泰e购SKU,
+                       e.goodNo 商品唯一编号,
+                       d.goodName 产品名称,
+                       e.goodName 平台物料名称,
+                       d.goodPrice 商品单价,
+                       e.comPrice 业务公司收入单价,
+                       d.totalPrice 商品总金额,
+                       e.com_total 业务公司收入总价,
+                       d.goodNum 商品数量,
+                       e.goodNum 产品数量,
+                       d.ownerName 资金创建人,
+                       c.apply_name 认领创建人,
+                       a.addtime    认领创建时间,
+                       b.status 认领审批状态,
+                       b.remark 驳回原因')
+                ->where($where)
+                ->order('b.id desc')
+                ->cursor();
+        $platType= [1=>"toB",2=>"toC"];
         foreach ($list as $value){
             $value["付款银行单位账号"] .=' ';
             $value["认领企业"] =Db::name("customer_info")->where(["companyNo"=>$value["认领企业"]])->value("companyName","");
             $value['状态'] = $status[$value['状态']] ?? '';
             $value['认领审批状态'] = $b_status[$value['认领审批状态']] ?? '';
+            $value['平台类型'] = $platType[$value['平台类型']] ?? '';
         	yield $value;
         }
     }

+ 1 - 4
app/admin/controller/OrderInv.php

@@ -351,11 +351,8 @@ class OrderInv extends Base{
             }
             if($param['status']==4){
                 \app\admin\model\Assoc::subOrder($param['invNo']);
-//                if (!empty($param['ItemRemark'])){
-//                    (new InvoiceOrder)->saveAll($param['ItemRemark']);
-//                };
             }
-            if($param['status']==7){
+            if($param['status']==7  || $param['status']==8){
                 \app\admin\model\Assoc::addOrder($param['invNo']);
             }
             $info->commit();

+ 8 - 6
app/admin/controller/OrderPay.php

@@ -1059,7 +1059,7 @@ class OrderPay extends Base{
                 $OrderCodeToLogNo = substr(makeNo('TRC'), 0, -3).str_pad($i,3,'0',STR_PAD_LEFT);
                 //资金数据更新处理
 				$balance = bcsub($all_trade['balance'], $value['trad_fee'], 2);
-				
+
                 $tradeUp=Db::name('trade')
                     ->where($all_trade)
                     ->update([
@@ -1069,7 +1069,7 @@ class OrderPay extends Base{
                         'updatetime' =>date("Y-m-d H:i:s"),
                     ]);
                if($tradeUp==false ) throw new Exception("{$value['tradNo']}资金更新失败");
-               
+
 				//订单数据更新处理
 				$update=[
                         'apay_fee' => bcadd($all_order['apay_fee'], $value['trad_fee'], 2),
@@ -1135,7 +1135,7 @@ class OrderPay extends Base{
 
     public function exportTrade(){
     	$param = $this->request->param(["name"=>"","bank"=>'',"start"=>'',"end"=>'',"status"=>'',"tradNo"=>'',
-    	"companyNo"=>'',"total_lower"=>'','total_upper'=>'','pcCode'=>''],"post","trim");
+    	"companyNo"=>'',"total_lower"=>'','total_upper'=>'','pcCode'=>'',"create_start"=>"","create_end"=>""],"post","trim");
 		$condition=[["is_del","=",0]];
 		$param['name']==""?: $condition[]=["trade_out","like","%{$param['name']}%"];
 		$param['bank']==""?: $condition[]=['trade_bank','like',"%{$param['bank']}%"];;
@@ -1147,19 +1147,21 @@ class OrderPay extends Base{
 		$param['total_lower']==""?: $condition[]=['total_fee','>=',$param['total_lower']];
 		$param['total_upper']==""?: $condition[]=['total_fee','<=',$param['total_upper']];
 		$param['pcCode']==""?: $condition[]=['pcCode',"like","%{$param['pcCode']}%"];
+        $param['create_start']==""?: $condition[]=['a.addtime','>=',startTime($param['create_start'])];
+        $param['create_end']==""?: $condition[]=['a.addtime','<=',endTime($param['create_end'])];
 		$list= \app\admin\model\Trade::alias("a")
 		->where($condition)
 		->leftJoin("trade_lib b","a.tradNo=b.tradNo")
 		->field(["a.tradNo","companyNo","companyName","trade_in_code","trade_in",'trade_in_account','trade_time',
 		'total_fee',"if(trade_type=0,'自营','平台') plat","if(status=1,'未认领',if(status=2,'部分认领','已认领')) status",
 		"used_fee","balance",'trade_bank','trade_account','trade_out','trade_used',"poCode","NdCode","customerName",
-		"pcCode","palt_po","skuCode","goodName","goodNum","platPrice","plat_total","tax","cat_code","cat_name","comPrice",
+		"pcCode","palt_po","skuCode","goodNo","goodName","goodNum","platPrice","plat_total","tax","unit","cat_code","cat_name","comPrice",
 		"com_total","apply_name","addtime"])
 		->select();
 		$header = ["资金编号","业务公司编号","业务公司名称","收款方公司编码","收款方公司名称","收款方账户","交易时间","业务公司收入总价",
 		"回款类型","状态","已认领金额","未认领金额","客户付款银行","客户付款银行账号","客户付款银行户名","交易用途","客户PO","客户DN",
-		"客户机构名称","资金批次号","平台采购PO号","泰e购SKU","平台物料名称","产品数量","平台收入单价","平台收入总价","税率","类目编号",
-		"类目名称","业务公司收入单价","业务公司收入总价","创建人","创建时间"];
+		"客户机构名称","资金批次号","平台采购PO号","泰e购SKU",'商品唯一编号',"平台物料名称","产品数量","平台收入单价","平台收入总价","税率",
+        "单位","类目编号","类目名称","业务公司收入单价","业务公司收入总价","创建人","创建时间"];
 		if($list->isEmpty()){
 			$header=["暂无数据"];
 		}

+ 34 - 1
app/admin/controller/Payment.php

@@ -998,7 +998,40 @@ class Payment extends Base
 
         $page =  isset($post['page'])&&$post['page']!="" ? intval($post['page']) :0;
         $size =  isset($post['size'])&&$post['size']!="" ? intval($post['size']) :10;
-        
+        $inv_status =  isset($post['inv_status'])&&$post['inv_status']!==''?intval($post['inv_status']):'';
+        if($inv_status!==''){
+        	if($inv_status==0){
+        		$condition[]=['a.inv_status','<>',3];
+        	}else{
+        		$condition[]=['a.inv_status','=',$inv_status];
+        	}
+        }
+        $invIs =  isset($post['inv_is'])&&$post['inv_is']!==''?intval($post['inv_is']):'';
+        if($invIs!==''){
+        	if($invIs==1){
+        		$condition[]=['a.winv_fee','<>',0];
+        	}else{
+        		$condition[]=['a.winv_fee','=',0];
+        	}
+        }
+        $payIs =  isset($post['pay_is'])&&$post['pay_is']!==''?intval($post['pay_is']):'';
+        if($payIs!==''){
+        	if($payIs==1){
+        		$condition[]=['a.wpay_fee','<>',0];
+        	}else{
+        		$condition[]=['a.wpay_fee','=',0];
+        	}
+        }
+
+        $pay_status =  isset($post['pay_status'])&&$post['pay_status']!==''?intval($post['pay_status']):'';
+        if($pay_status!==''){
+        	if($pay_status==0){
+        		$condition[]=['a.pay_status','<>',3];
+        	}else{
+        		$condition[]=['a.pay_status','=',$pay_status];
+        	}
+
+        }
         $list = CgdInfo::alias("a")
                ->leftJoin("pay_info b","a.sequenceNo=b.cgdNo and b.is_del=0 and b.status=1")
                ->where($condition)

+ 5 - 0
app/admin/controller/Sale.php

@@ -146,6 +146,11 @@ class Sale extends Base{
         }
          $cat_status= isset($post['cat_status'])&&$post['cat_status']!=="" ? intval($post['cat_status']) :"";
          if($cat_status!=='') $condition[]=["b.status","=",$cat_status];
+
+         $goodNo= isset($post['goodNo'])&&$post['goodNo']!=="" ? trim($post['goodNo']) :"";
+         if($goodNo!=='') $condition[]=["a.goodNo","like","%$goodNo%"];
+         $goodName= isset($post['goodName'])&&$post['goodName']!=="" ? trim($post['goodName']) :"";
+         if($goodName!=='') $condition[]=["a.goodName","like","%$goodName%"];
         $count =Db::name("qrd_info")
         ->alias("a")
         ->leftJoin("good b","a.goodNo=b.spuCode")->where($condition)->count();

+ 2 - 1
app/admin/listener/ComonQrd.php

@@ -29,7 +29,7 @@ class ComonQrd
 		}
 		if($event['type']=='rinv'){
 		    $this->returnInv($event);
-		    //$this->InvToPay($event,false);
+		    $this->InvToPay($event,false);
 		}
 		if($event['type']=='check')$this->checkPay($event);
     }
@@ -86,6 +86,7 @@ class ComonQrd
 		            		$qrd['pay_status'] = ($qrd['wpay_fee']==0 &&$item->pay_fee==0) ? 3:($qrd['apay_fee']==0?1:2);
 		            	}
 		            }else{
+		                if($item->pay_tag_fee==0) continue;
                         $tag_temp['tag_fee']= $payArr[$item->sequenceNo];
                         $tag_fee = ($item->pay_tag_fee>$payArr[$item->sequenceNo])?$payArr[$item->sequenceNo]:$item->pay_tag_fee;
                         $qrd['pay_tag_fee']=$item->pay_tag_fee-$tag_fee;

+ 27 - 18
app/admin/model/Assoc.php

@@ -17,8 +17,9 @@ class Assoc extends Model
     {
         $list = self::where(["viceCode"=>$invNo,"status"=>1,"type"=>"1"])->field("id,orderCode,cancel_fee")->select();
         if(!$list->isEmpty()){
-            $order= QrdInfo::whereIn("sequenceNo",$list->column("orderCode"))
-            ->column("id,sequenceNo,winv_fee,inv_fee,ainv_fee,invtime,inv_status,status,pay_status","sequenceNo");
+            try{
+                 $order= QrdInfo::whereIn('sequenceNo',$list->column('orderCode'))
+            ->column('id,sequenceNo,winv_fee,inv_fee,ainv_fee,invtime,inv_status,status,pay_status','sequenceNo');
             foreach ($list as $k=>$v){
                 if(!isset($order[$v['orderCode']])) throw new \Exception("订单{$v['orderCode']}未找到数据");
                 if($v['cancel_fee']>0){
@@ -27,13 +28,17 @@ class Assoc extends Model
                     }
                     $order[$v['orderCode']]['inv_fee']-=$v['cancel_fee'];
                     $order[$v['orderCode']]['ainv_fee']+=$v['cancel_fee'];
-                    $order[$v['orderCode']]['invtime']=date("Y-m-d H:i:s");
+                    $order[$v['orderCode']]['invtime']=date('Y-m-d H:i:s');
                     $order[$v['orderCode']]['inv_status']= $order[$v['orderCode']]['winv_fee']==0 &&$order[$v['orderCode']]['inv_fee']==0 ? 3 : 2;
-                    $order[$v['orderCode']]['status']= $order[$v['orderCode']]['pay_status']==0 &&$order[$v['orderCode']]['inv_status']==0 ? 0 : 1;
+                    $order[$v['orderCode']]['status']= $order[$v['orderCode']]['pay_status']==1 &&$order[$v['orderCode']]['inv_status']==1 ? 0 : 1;
                 }
             }
            (new QrdInfo())->saveAll($order);
-            self::where(["id"=>$list->column('id')])->save(['status'=>2,'assoc_time'=>date("Y-m-d H:i:s")]);
+            self::where(['id'=>$list->column('id')])->save(['status'=>2,'assoc_time'=>date('Y-m-d H:i:s')]);
+            }catch (\Exception $exception){
+                throw new \Exception($exception->getMessage());
+            }
+
         }
     }
     public static function addOrder($invNo)
@@ -51,7 +56,7 @@ class Assoc extends Model
                     $order[$v['orderCode']]['inv_fee']-=$v['cancel_fee'];
                     $order[$v['orderCode']]['winv_fee']+=$v['cancel_fee'];
                     $order[$v['orderCode']]['inv_status']= $order[$v['orderCode']]['ainv_fee']==0 &&$order[$v['orderCode']]['inv_fee']==0 ? 1 : 2;
-                    $order[$v['orderCode']]['status']= $order[$v['orderCode']]['pay_status']==0 &&$order[$v['orderCode']]['inv_status']==0 ? 0 : 1;
+                    $order[$v['orderCode']]['status']= $order[$v['orderCode']]['pay_status']==1 &&$order[$v['orderCode']]['inv_status']==1 ? 0 : 1;
                 }
             }
            (new QrdInfo())->saveAll($order);
@@ -75,7 +80,7 @@ class Assoc extends Model
                     $order[$v['orderCode']]['ainv_fee']-=$v['cancel_fee'];
                     $order[$v['orderCode']]['winv_fee']+=$v['cancel_fee'];
                     $order[$v['orderCode']]['inv_status']= $order[$v['orderCode']]['ainv_fee']==0 &&$order[$v['orderCode']]['inv_fee']==0 ? 1 : 2;
-                    $order[$v['orderCode']]['status']= $order[$v['orderCode']]['pay_status']==0 &&$order[$v['orderCode']]['inv_status']==0 ? 0 : 1;
+                    $order[$v['orderCode']]['status']= $order[$v['orderCode']]['pay_status']==1 &&$order[$v['orderCode']]['inv_status']==1 ? 0 : 1;
                 }
             }
            (new QrdInfo())->saveAll($order);
@@ -86,17 +91,21 @@ class Assoc extends Model
 
     public static function CheckQrd($orderCode,&$data)
     {
-        $asscoinfo =self::where(['orderCode'=>$orderCode,'status'=>[1,2],'is_del'=>0])->column
-        	                    ('viceCode','type');
-         if(isset($asscoinfo[1])){
-            $pool = InvoicePool::where('invNo',$asscoinfo[1])->findOrEmpty();
-            $temp=['type'=>'结算销售单开票申请','username'=> $pool->apply_name,'orderCode'=>$asscoinfo[1],'companyName'=>$pool->inv_company];
-            $data[]=$temp;
+        $asscoinfo =self::where(['orderCode'=>$orderCode,'status'=>[1,2],'is_del'=>0])->column('viceCode,type');
+        if(!empty($asscoinfo)){
+             foreach ($asscoinfo as $k=>$v){
+            if($v['type']==1){
+                $pool = InvoicePool::where('invNo',$v['viceCode'])->findOrEmpty();
+                $temp=['type'=>'结算销售单开票申请','username'=> $pool->apply_name,'orderCode'=>$v['viceCode'],'companyName'=>$pool->inv_company];
+                $data[]=$temp;
+            }
+             if($v['type']==2){
+                $pool = TradePool::with(['company'])->where('logNo',$v['viceCode'])->findOrEmpty();
+                $temp=['type'=>'结算销售单资金认领','username'=> $pool->apply_name,'orderCode'=>$v['viceCode'],'companyName'=>$pool->companyName];
+                 $data[]=$temp;
+              }
+            }
         }
-         if(isset($asscoinfo[2])){
-            $pool = TradePool::with(["company"])->where('logNo',$asscoinfo[2])->findOrEmpty();
-            $temp=['type'=>'结算销售单资金认领','username'=> $pool->apply_name,'orderCode'=>$asscoinfo[2],'companyName'=>$pool->companyName];
-             $data[]=$temp;
-          }
+
     }
 }

+ 24 - 2
app/admin/model/InvoiceTicket.php

@@ -3,7 +3,8 @@ declare (strict_types = 1);
 
 namespace app\admin\model;
 
-use think\facade\Log;use think\Model;
+use think\facade\Log;
+use think\Model;
 
 /**
  * @mixin \think\Model
@@ -16,5 +17,26 @@ class InvoiceTicket extends Model
     public function setItemAttr($v){
       return json_encode($v,JSON_UNESCAPED_UNICODE);
     }
-
+    public static function onAfterWrite(Model $model){
+        Log::info('InvoiceInfo::OnAfterWrite'.json_encode($model->toArray()));
+            if($model->status==1 && !empty($model['item'])){
+                (new  InvoiceItem)->saveAll(array_map(function ($item)use($model) {
+                              return [
+                                  'invoiceCode'=>$model->invNo,
+                                  'order_type'=>1,
+                                  'good_name'=>$item['XMMC'],
+                                  'unit'=>$item['DW'],
+                                  'num'=>$item['SPSL'],
+                                  'specinfo'=>$item['GGXH'],
+                                  'unit_price'=>$item['DJ'],
+                                  'amount'=>$item['JE'],
+                                  'tax_amount'=>$item['SE'],
+                                  'tax'=>$item['SL'],
+                                  'cat_code'=>$item['SPBM'],
+                                  'total_amount'=>bcadd($item['amount'],$item['tax'],2),
+                                  'balance_amount'=>bcadd($item['amount'],$item['tax'],2),
+                              ];
+               },$model['item']));
+            }
+   }
 }

+ 5 - 6
app/command/handleCxData.php

@@ -315,7 +315,7 @@ class handleCxData extends command
 						if($data['cgdNo']!=''){
 								Db::name('cgd_info')->where(['sequenceNo'=>$data['cgdNo']])->update
 								(['qrdSend'=>$data['send_status']]);
-							}
+						}
 					
 				    }
 				    else {
@@ -337,10 +337,8 @@ class handleCxData extends command
 					    $exists_cgd=Db::name('cgd_info')
 					                  ->whereIn('sequenceNo' , $data['cgdNo'])
 					                  ->field('id,status')->findOrEmpty();
-					    $data['qrdSend'] = Db::name('qrd_info')->where(['cgdNo'=>$data['cgdNo']])->value
-					    ('sendStatus',1);
+					    $data['qrdSend'] = Db::name('qrd_info')->where(['cgdNo'=>$data['cgdNo']])->value('sendStatus',1);
 					    if (!empty($exists_cgd)) {
-
 						    //未对账,更新
 						    if ($exists_cgd['status'] == 0) {
 
@@ -405,6 +403,7 @@ class handleCxData extends command
 									      'sendType'=>$data['send_type'] ,//发货方式',
 									      'bkCreater'=>$data['bkcreater'] ,//备库申请人',
 									      'sendStatus'=>$data['send_status'] ,//发货状态',
+									      'qrdSend'=>($data['is_stock']==1 ||isset($data['mainCode'])) ?$data['send_status']:$data['qrdSend'] ,
 									      'wsendNum'=>$data['wsend_num'] ,//未发货数量',
 									      'sendNum'=>$data['send_num'] ,//已发货数量',
 									      'wareHouse'=>$data['wsm_code'] ,//仓库名称',
@@ -476,7 +475,7 @@ class handleCxData extends command
 									      'sendType'=>$data['send_type'] ,//发货方式',
 									      'bkCreater'=>$data['bkcreater'] ,//备库申请人',
 									      'sendStatus'=>$data['send_status'] ,//发货状态',
-									      'qrdSend'=>$data['qrdSend'] ,//发货状态',
+									      'qrdSend'=>($data['is_stock']==1 ||isset($data['mainCode']))?$data['send_status']:$data['qrdSend'] ,//发货状态',
 									      'wsendNum'=>$data['wsend_num'] ,//未发货数量',
 									      'sendNum'=>$data['send_num'] ,//已发货数量',
 									      'wareHouse'=>$data['wsm_code'] ,//仓库名称',
@@ -558,7 +557,7 @@ class handleCxData extends command
 							    'sendType'=>$data['send_type'] ,//发货方式',
 							    'bkCreater'=>$data['bkcreater'] ,//备库申请人',
 							    'sendStatus'=>$data['send_status'] ,//发货状态',
-							    'qrdSend'=>$data['qrdSend'] ,
+							    'qrdSend'=>($data['is_stock']==1 ||isset($data['mainCode'])) ?$data['send_status']:$data['qrdSend'] ,
 							    'wsendNum'=>$data['wsend_num'] ,//未发货数量',
 							    'sendNum'=>$data['send_num'] ,//已发货数量',
 							    'wareHouse'=>$data['wsm_code'] ,//仓库名称',

+ 79 - 186
composer.lock

@@ -18,13 +18,7 @@
                 "type": "zip",
                 "url": "https://api.github.com/repos/dodgepudding/wechat-php-sdk/zipball/3a9b9601a07797497e8c428cfd20a29d37a66a35",
                 "reference": "3a9b9601a07797497e8c428cfd20a29d37a66a35",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.1.0"
@@ -75,13 +69,7 @@
                 "type": "zip",
                 "url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/1441011fb7ecdd8cc689878f54f8b58a6805f870",
                 "reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "shasum": ""
             },
             "require": {
                 "ext-mbstring": "*",
@@ -148,13 +136,7 @@
                 "type": "zip",
                 "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
                 "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "shasum": ""
             },
             "require": {
                 "php": ">=7.2.0"
@@ -192,31 +174,25 @@
         },
         {
             "name": "psr/http-message",
-            "version": "1.0.1",
+            "version": "1.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/php-fig/http-message.git",
-                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+                "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
-                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
+                "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
+                "shasum": ""
             },
             "require": {
-                "php": ">=5.3.0"
+                "php": "^7.2 || ^8.0"
             },
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "1.0.x-dev"
+                    "dev-master": "1.1.x-dev"
                 }
             },
             "autoload": {
@@ -245,9 +221,9 @@
                 "response"
             ],
             "support": {
-                "source": "https://github.com/php-fig/http-message/tree/master"
+                "source": "https://github.com/php-fig/http-message/tree/1.1"
             },
-            "time": "2016-08-06T14:39:51+00:00"
+            "time": "2023-04-04T09:50:52+00:00"
         },
         {
             "name": "psr/log",
@@ -261,13 +237,7 @@
                 "type": "zip",
                 "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
                 "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.3.0"
@@ -317,13 +287,7 @@
                 "type": "zip",
                 "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
                 "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "shasum": ""
             },
             "require": {
                 "php": ">=5.3.0"
@@ -364,23 +328,17 @@
         },
         {
             "name": "topthink/framework",
-            "version": "v6.1.1",
+            "version": "v6.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/top-think/framework.git",
-                "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210"
+                "reference": "57d1950a1844ef8d3098ea290032aeb92e2e32c3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/top-think/framework/zipball/2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
-                "reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/top-think/framework/zipball/57d1950a1844ef8d3098ea290032aeb92e2e32c3",
+                "reference": "57d1950a1844ef8d3098ea290032aeb92e2e32c3",
+                "shasum": ""
             },
             "require": {
                 "ext-json": "*",
@@ -391,7 +349,7 @@
                 "psr/log": "~1.0",
                 "psr/simple-cache": "^1.0",
                 "topthink/think-helper": "^3.1.1",
-                "topthink/think-orm": "^2.0"
+                "topthink/think-orm": "^2.0|^3.0"
             },
             "require-dev": {
                 "guzzlehttp/psr7": "^2.1.0",
@@ -429,29 +387,23 @@
             ],
             "support": {
                 "issues": "https://github.com/top-think/framework/issues",
-                "source": "https://github.com/top-think/framework/tree/v6.1.1"
+                "source": "https://github.com/top-think/framework/tree/v6.1.5"
             },
-            "time": "2022-10-26T03:48:53+00:00"
+            "time": "2024-04-16T02:01:19+00:00"
         },
         {
             "name": "topthink/think-helper",
-            "version": "v3.1.6",
+            "version": "v3.1.10",
             "source": {
                 "type": "git",
                 "url": "https://github.com/top-think/think-helper.git",
-                "reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff"
+                "reference": "ac66cc0859a12cd5d73258f50f338aadc95e9b46"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/top-think/think-helper/zipball/769acbe50a4274327162f9c68ec2e89a38eb2aff",
-                "reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/top-think/think-helper/zipball/ac66cc0859a12cd5d73258f50f338aadc95e9b46",
+                "reference": "ac66cc0859a12cd5d73258f50f338aadc95e9b46",
+                "shasum": ""
             },
             "require": {
                 "php": ">=7.1.0"
@@ -481,33 +433,27 @@
             "description": "The ThinkPHP6 Helper Package",
             "support": {
                 "issues": "https://github.com/top-think/think-helper/issues",
-                "source": "https://github.com/top-think/think-helper/tree/v3.1.6"
+                "source": "https://github.com/top-think/think-helper/tree/v3.1.10"
             },
-            "time": "2021-12-15T04:27:55+00:00"
+            "time": "2024-11-21T01:47:51+00:00"
         },
         {
             "name": "topthink/think-multi-app",
-            "version": "v1.0.15",
+            "version": "v1.1.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/top-think/think-multi-app.git",
-                "reference": "387e0dac059c20f92cac5da41a871e10829c1c97"
+                "reference": "46df2e8be05ea02ae40f32140d656133aedfe4a5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/387e0dac059c20f92cac5da41a871e10829c1c97",
-                "reference": "387e0dac059c20f92cac5da41a871e10829c1c97",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/46df2e8be05ea02ae40f32140d656133aedfe4a5",
+                "reference": "46df2e8be05ea02ae40f32140d656133aedfe4a5",
+                "shasum": ""
             },
             "require": {
                 "php": ">=7.1.0",
-                "topthink/framework": "^6.0"
+                "topthink/framework": "^6.0|^8.0"
             },
             "type": "library",
             "extra": {
@@ -532,32 +478,26 @@
                     "email": "liu21st@gmail.com"
                 }
             ],
-            "description": "thinkphp6 multi app support",
+            "description": "thinkphp multi app support",
             "support": {
                 "issues": "https://github.com/top-think/think-multi-app/issues",
-                "source": "https://github.com/top-think/think-multi-app/tree/v1.0.15"
+                "source": "https://github.com/top-think/think-multi-app/tree/v1.1.0"
             },
-            "time": "2022-10-26T08:03:06+00:00"
+            "time": "2024-11-22T04:11:23+00:00"
         },
         {
             "name": "topthink/think-orm",
-            "version": "v2.0.56",
+            "version": "v2.0.62",
             "source": {
                 "type": "git",
                 "url": "https://github.com/top-think/think-orm.git",
-                "reference": "75b8512736daaa056d511f42c15bed87c9f3605a"
+                "reference": "e53bfea572a133039ad687077120de5521af617f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/top-think/think-orm/zipball/75b8512736daaa056d511f42c15bed87c9f3605a",
-                "reference": "75b8512736daaa056d511f42c15bed87c9f3605a",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/top-think/think-orm/zipball/e53bfea572a133039ad687077120de5521af617f",
+                "reference": "e53bfea572a133039ad687077120de5521af617f",
+                "shasum": ""
             },
             "require": {
                 "ext-json": "*",
@@ -596,34 +536,28 @@
             ],
             "support": {
                 "issues": "https://github.com/top-think/think-orm/issues",
-                "source": "https://github.com/top-think/think-orm/tree/v2.0.56"
+                "source": "https://github.com/top-think/think-orm/tree/v2.0.62"
             },
-            "time": "2022-12-15T02:52:53+00:00"
+            "time": "2024-09-22T06:17:47+00:00"
         }
     ],
     "packages-dev": [
         {
             "name": "symfony/polyfill-mbstring",
-            "version": "v1.27.0",
+            "version": "v1.31.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-mbstring.git",
-                "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
+                "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
-                "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
+                "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
+                "shasum": ""
             },
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             "provide": {
                 "ext-mbstring": "*"
@@ -633,9 +567,6 @@
             },
             "type": "library",
             "extra": {
-                "branch-alias": {
-                    "dev-main": "1.27-dev"
-                },
                 "thanks": {
                     "name": "symfony/polyfill",
                     "url": "https://github.com/symfony/polyfill"
@@ -673,7 +604,7 @@
                 "shim"
             ],
             "support": {
-                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
+                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
             },
             "funding": [
                 {
@@ -689,49 +620,32 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2022-11-03T14:55:06+00:00"
+            "time": "2024-09-09T11:45:10+00:00"
         },
         {
             "name": "symfony/polyfill-php72",
-            "version": "v1.27.0",
+            "version": "v1.31.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-php72.git",
-                "reference": "869329b1e9894268a8a61dabb69153029b7a8c97"
+                "reference": "fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/869329b1e9894268a8a61dabb69153029b7a8c97",
-                "reference": "869329b1e9894268a8a61dabb69153029b7a8c97",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce",
+                "reference": "fa2ae56c44f03bed91a39bfc9822e31e7c5c38ce",
+                "shasum": ""
             },
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
-            "type": "library",
+            "type": "metapackage",
             "extra": {
-                "branch-alias": {
-                    "dev-main": "1.27-dev"
-                },
                 "thanks": {
                     "name": "symfony/polyfill",
                     "url": "https://github.com/symfony/polyfill"
                 }
             },
-            "autoload": {
-                "files": [
-                    "bootstrap.php"
-                ],
-                "psr-4": {
-                    "Symfony\\Polyfill\\Php72\\": ""
-                }
-            },
             "notification-url": "https://packagist.org/downloads/",
             "license": [
                 "MIT"
@@ -755,7 +669,7 @@
                 "shim"
             ],
             "support": {
-                "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.0"
+                "source": "https://github.com/symfony/polyfill-php72/tree/v1.31.0"
             },
             "funding": [
                 {
@@ -771,36 +685,27 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2022-11-03T14:55:06+00:00"
+            "time": "2024-09-09T11:45:10+00:00"
         },
         {
             "name": "symfony/polyfill-php80",
-            "version": "v1.27.0",
+            "version": "v1.31.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/polyfill-php80.git",
-                "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
+                "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
-                "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
+                "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
+                "shasum": ""
             },
             "require": {
-                "php": ">=7.1"
+                "php": ">=7.2"
             },
             "type": "library",
             "extra": {
-                "branch-alias": {
-                    "dev-main": "1.27-dev"
-                },
                 "thanks": {
                     "name": "symfony/polyfill",
                     "url": "https://github.com/symfony/polyfill"
@@ -844,7 +749,7 @@
                 "shim"
             ],
             "support": {
-                "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
+                "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
             },
             "funding": [
                 {
@@ -860,7 +765,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2022-11-03T14:55:06+00:00"
+            "time": "2024-09-09T11:45:10+00:00"
         },
         {
             "name": "symfony/var-dumper",
@@ -874,13 +779,7 @@
                 "type": "zip",
                 "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1069c7a3fca74578022fab6f81643248d02f8e63",
                 "reference": "1069c7a3fca74578022fab6f81643248d02f8e63",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "shasum": ""
             },
             "require": {
                 "php": ">=7.1.3",
@@ -959,27 +858,21 @@
         },
         {
             "name": "topthink/think-trace",
-            "version": "v1.5",
+            "version": "v1.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/top-think/think-trace.git",
-                "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7"
+                "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/top-think/think-trace/zipball/55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
-                "reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7",
-                "shasum": "",
-                "mirrors": [
-                    {
-                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                        "preferred": true
-                    }
-                ]
+                "url": "https://api.github.com/repos/top-think/think-trace/zipball/136cd5d97e8bdb780e4b5c1637c588ed7ca3e142",
+                "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142",
+                "shasum": ""
             },
             "require": {
                 "php": ">=7.1.0",
-                "topthink/framework": "^6.0"
+                "topthink/framework": "^6.0|^8.0"
             },
             "type": "library",
             "extra": {
@@ -1010,9 +903,9 @@
             "description": "thinkphp debug trace",
             "support": {
                 "issues": "https://github.com/top-think/think-trace/issues",
-                "source": "https://github.com/top-think/think-trace/tree/v1.5"
+                "source": "https://github.com/top-think/think-trace/tree/v1.6"
             },
-            "time": "2022-10-26T07:56:45+00:00"
+            "time": "2023-02-07T08:36:32+00:00"
         }
     ],
     "aliases": [],