wugg 2 years ago
parent
commit
be2dce77f0
2 changed files with 51 additions and 60 deletions
  1. 2 1
      app/admin/controller/SaleReport.php
  2. 49 59
      app/command/NowReportHandle.php

+ 2 - 1
app/admin/controller/SaleReport.php

@@ -293,7 +293,7 @@ class SaleReport extends Base
 
         $data = Db::name('sale')
             ->alias('s')
-            ->field('s.apply_name,s.addtime,s.orderCode,csi.companyName,s.good_name,s.good_num,s.sale_price,s.total_price,s.is_stock,s.order_type,csi.itemid,s.good_code,s.apply_id')
+            ->field('s.apply_name,s.addtime,s.orderCode,csi.companyName,s.good_name,s.good_num,s.sale_price,s.total_price,s.is_stock,s.order_type,csi.itemid,s.good_code,s.apply_id,a.pay_id')
             ->leftJoin('customer_info csi', 'csi.companyNo=s.customer_code')
             ->where($where)
             ->page($param['page'], $param['size'])
@@ -315,6 +315,7 @@ class SaleReport extends Base
             $value['is_stock'] = isset($this->all_stock[$value['is_stock']]) ? $this->all_stock[$value['is_stock']] : '';
             $value['order_type'] = isset($this->all_order_type[$value['order_type']]) ? $this->all_order_type[$value['order_type']] : '';
             $value['creater_company'] = get_company_name_by_uid($value['apply_id']);//获取创建人的所属部门
+            $value['pay_id'] = Db::name("pay")->where(["id"=>$value['pay_id']])->value("pay_name",'');
 
             $list[] = $value;
         }

+ 49 - 59
app/command/NowReportHandle.php

@@ -544,55 +544,55 @@ class NowReportHandle extends Command
     }
     //网络部出入库
     public function  GetWlb($start,$end){
-        $db =Db::connect("mysql3");
+        $db =Db::connect("mysql_cxinv");
         $list =$db->name("cgd_info")
-          ->where(['ShortText1617866362204'=>'客服确认单'])->whereBetweenTime('createdTime',$start,$end)->field(
+          ->where(['name'=>'网络部采购单'])->whereBetweenTime('createdTime',$start,$end)->field(
             "year(createdTime) AS `年`,
 					month(createdTime) AS `月`,
 					dayofmonth(createdTime) AS `日`,
-					ShortText1618270466672 '公司名称',
+					companyName '公司名称',
 					department '业务部门',
 					ownerName '业务人员',
-					ShortText1617866362204 '订单类型',
+					'网络部采购单' '订单类型',
 					'' as '商品类型',
 					'' as '发货编号',
-					Number1618240600907 '本次发货数量',
+					sendNum '本次发货数量',
 					createdTime '本次发货时间',
-					ShortText1617866360004 '确认单编号',
-					ShortText1617861001482 '商品编号',
-					ShortText1617865626160 '一级分类',
-					''as  '二级分类',
-					'' as  '三级分类',
-					 '' as '财务核算编码',
-					 ShortText1617861966146 as '商品名称',
-					 ShortText1617865685744 as '单位',
-					 Number1618240600907 '下单数量',
+					qrdCode '确认单编号',
+					goodNo '商品编号',
+					firstCat '一级分类',
+					secCat as  '二级分类',
+					thirdCat as  '三级分类',
+					 fundCode as '财务核算编码',
+					 goodName as '商品名称',
+					 goodUnit as '单位',
+					 goodNum '下单数量',
 					 '' AS `销售货款`,
-					 ShortText1618315935182 as '采购单单号',
+					 sequenceNo as '采购单单号',
 					 ownerName '采购员',
-		            Number1617865804813 AS `采购裸价`,
-		            Number1617865807879 AS `加标费`,
-		            Number1617865810822 AS `包装费`,
-		            Number1617865813284 AS `证书费`,
-		            Number1617865816181 AS `开模费`,
-		            number1618240204358 AS `工艺费`,
-		            number1618240287778 AS `物流费`,
-		            Number1617865818517 AS `成本合计`,
-		            Number1618240685904 AS `采购货款`,
-		            ShortText1617865688485 AS `采购税点`, 
-				    ShortText1620399144946 AS `供应商名称`,
+		            barePrice AS `采购裸价`,
+		            markPrice AS `加标费`,
+		            packPrice AS `包装费`,
+		            certPrice AS `证书费`,
+		            openPrice AS `开模费`,
+		            costPrice AS `工艺费`,
+		            deliveryPrice AS `物流费`,
+		            goodPrice AS `成本合计`,
+		            totalPrice AS `采购货款`,
+		            tax AS `采购税点`, 
+				    supplierName AS `供应商名称`,
 					'否'as '是否库存品',
-		            '' as '发货方式',
+		            '包邮' as '发货方式',
 		            '' AS `退货编号`,
-					'' AS `退货数量`,
-					'' as '退货金额',
+					thNum AS `退货数量`,
+					th_fee as '退货金额',
 					'' as '售前退货数量',
 					'' as '售前退货金额'
                     ")->cursor();
         $data=[];
         foreach($list as $value){
-            $value['销售货款'] = $db->name("qrd_info")->where(['sequenceNo'=>$value['确认单编号']])->value('Number1618248813613','');
-            $value['财务核算编码'] = $db->name("cat")->where(['cat_name'=>$value['一级分类']])->value('fund_code','');
+            $value['销售货款'] = $db->name("qrd_info")->where(['sequenceNo'=>$value['确认单编号']])->value('totalPrice','');
+//            $value['财务核算编码'] = $db->name("cat")->where(['cat_name'=>$value['一级分类']])->value('fund_code','');
             yield $data[] = $value;
         }
         return $data;
@@ -870,55 +870,45 @@ class NowReportHandle extends Command
 	* @throws \think\db\exception\ModelNotFoundException
 	 */
     private function EveryDayStock(string $start,string $end){
-		$list = Db::name("good_stock_info")->alias("a")
-		->leftJoin("good_stock b","a.stockid=b.id")
-		->leftJoin("purchease_in c","c.bnCode=a.bnCode")
-		->leftJoin("purchease_order d","c.cgdNo=d.cgdNo")
-		->leftJoin("purchease e","d.bkcode=e.bk_code")
+		$list = Db::name("good_stock")->alias("b")
+//		->leftJoin("good_stock b","a.stockid=b.id")
+//		->leftJoin("purchease_in c","c.bnCode=a.bnCode")
+//		->leftJoin("purchease_order d","c.cgdNo=d.cgdNo")
+//		->leftJoin("purchease e","d.bkcode=e.bk_code")
 		->leftJoin("good f","b.spuCode=f.spuCode")
 		->leftJoin("warehouse_info j","b.wsm_code=j.wsm_code")
-		->field("	e.companyNo '业务公司',
-		e.apply_id '申请部门',
-		e.apply_name '申请人',
-		e.addtime '备库创建时间',
-		e.bk_code '备库单号',
-		a.bnCode 'BN编号' ,
-		a.addtime '入库时间',
-		c.cgdNo '采购单编号' ,
+		->field("	f.companyNo '业务公司',
 		f.spuCode '产品编号' ,
-		f.good_name '产品名称' ,
-		e.good_num '备库数量' ,
 		f.cat_id '一级分类' ,
+		f.good_name '产品名称' ,
 		f.cat_id,
-		'' as '财务核算编',
+		'' as '财务核算编号',
 		f.tax as '税率',
-		a.origin_price '成本单价',
+		'' as '成本单价',
 		b.wait_in_stock '待入库数量',
 		b.wait_out_stock '待出库数量',
 		b.total_stock '当前库存数量',
 		b.usable_stock '可用库存数量',
-			a.total_num 'BN总数',
-		a.balance_num 'BN库存数',
-		a.used_num 'BN已使用数量',
-		DATEDIFF(NOW(),a.addtime) '库存天数',
 		f.supplierNo '采购员',
-		d.supplier_name '供应商名称',
-		j.`name` '仓库名称'")
+		'' as '供应商名称',
+		j.`name` '仓库名称',
+		''as '最新备库时间'
+		")
 		->where(["f.is_stock"=>1])
-		->whereBetween("a.updatetime",[$start,$end])
+//		->whereBetween("b.updatetime",[$start,$end])
 		->cursor();
 		foreach ($list as $value){
-			$value['申请部门'] = Db::name("depart_user")->alias("a")->leftJoin("company_item ci", "a.itemid=ci.id")->where(["a.uid" => $value['申请部门'], "a.status" => 1, "a.is_del" => 0])->value('ci.name', '');
+//			$value['申请部门'] = Db::name("depart_user")->alias("a")->leftJoin("company_item ci", "a.itemid=ci.id")->where(["a.uid" => $value['申请部门'], "a.status" => 1, "a.is_del" => 0])->value('ci.name', '');
 			$value['业务公司'] = Db::name("business")->where(["companyNo" => $value['业务公司']])->value('company', '');
 			$cat = made($value['cat_id']);
 			 $value['财务核算编号'] = Db::name("cat")->where(["id"=>$value['cat_id']])->value("fund_code",'');
 			 unset($value['cat_id']);
              $value['一级分类'] = isset($cat[0]['name']) ? $cat[0]['name'] : "";
              $supplier = Db::name("supplier")->where(["code"=>$value['采购员']])->field("person,name")->find();
-             if($value['供应商名称']==''){
-             	$value['供应商名称']= $supplier['name']??"";
-             }
+             $value['供应商名称']= $supplier['name']??"";
              $value['采购员']= $supplier['person']??"";
+             $value['最新备库时间']= Db::name("purchease_order")->where(["spuCode"=>$value['产品编号'],"status"=>[2,3]])
+             ->order("id desc")->value("addtime",'');
              yield $value;
 		}
     }