wugg 2 years ago
parent
commit
056ddead68
1 changed files with 8 additions and 5 deletions
  1. 8 5
      app/command/NowReportHandle.php

+ 8 - 5
app/command/NowReportHandle.php

@@ -317,7 +317,7 @@ class NowReportHandle extends Command
             ->leftJoin("supplier ws","ws.code=wpo.supplierNo")
             ->where('woo.status',">=", 2)
             ->where('woo.is_del',"=", 0)
-            ->whereBetween('woo.addtime', [$start, $end])
+            ->whereBetween('woo.sendtime', [$start, $end])
             ->field(" year(`a`.`addtime`) AS `年`,
             month(`a`.`addtime`) AS `月`,
             dayofmonth(`a`.`addtime`) AS `日`,
@@ -378,7 +378,7 @@ class NowReportHandle extends Command
                 $value['单位']=Db::name("unit")->where(["id"=>$value['单位']])->value("unit",'');
                 if($value['是否库存品']==1){
                     $sendtype = Db::name("purchease_order")->alias("a")->leftJoin("purchease_in b","a.cgdNo=b.cgdNo and b.is_del=0")
-                        ->where(["bkcode"=>$value['发货方式'],"order_type"=>1])->order("b.addtime desc")
+                        ->where(["bkcode"=>$value['发货方式'],"order_type"=>1,"order_source"=>0])->order("b.addtime desc")
                         ->value("b.sendtype",'');
                     $value['是否库存品']='是';
                 }else{
@@ -667,7 +667,7 @@ class NowReportHandle extends Command
             ->leftJoin("good_zixun wgz", "wgz.spuCode=wpo.spuCode")
             ->leftJoin("supplier ws", "ws.code=wpo.supplierNo")
             ->where('woo.status', ">=", 2)
-            ->whereBetween('woo.addtime', [$start, $end])
+            ->whereBetween('woo.sendtime', [$start, $end])
             ->field(" year(`a`.`addtime`) AS `年`,month(`a`.`addtime`) AS `月`,dayofmonth(`a`.`addtime`) AS `日`,a.supplierNo as '公司名称', a.apply_id '业务部门名称' ,a.apply_name as '业务人员',a.order_type as '订单类型',a.good_type as '商品类型',woo.outCode '发货编号',`woo`.`send_num` AS `本次发货数量`,`woo`.`sendtime` AS `本次发货时间`,`woo`.`orderCode` AS `确认单编号`,`a`.`good_code` AS `商品编号`,'' as '一级分类','' as '二级分类',a.cat_id as '三级分类','' as '财务核算编码',a.good_name as '商品名称',ifnull( `wgb`.`good_unit`, `wgz`.`good_unit` ) as '单位',`a`.`good_num` AS `下单数量`,`wpo`.`cgdNo` AS `采购单单号`,`wpo`.`cgder` AS `采购员`,`ws`.`name` AS `供应商名称`,`wgb`.`is_stock`  as '是否库存品',if (`wgb`.`is_stock`=1,wpo.bkcode,wpo.cgdNo) as '发货方式',ifnull( `wor`.`thNo`, '' ) AS `退货编号`,ifnull( `wor`.`return_num`, '' ) AS `退货数量`,'' as '售前退货数量'")
             ->cursor();
         $order_tyepe = ["库存销售", '非库存销售', '咨询销售', '项目销售', '平台库存销售', '平台非库存销售'];
@@ -685,7 +685,10 @@ class NowReportHandle extends Command
             $value['三级分类'] = isset($cat[2]['name']) ? $cat[2]['name'] : "";
             $value['单位'] = Db::name("unit")->where(["id" => $value['单位']])->value("unit", '');
             if ($value['是否库存品'] == 1) {
-                $sendtype = Db::name("purchease_order")->alias("a")->leftJoin("purchease_in b", "a.cgdNo=b.cgdNo")->where(["bkcode" => $value['发货方式'], "order_type" => 1])->order("b.addtime desc")->value("b.sendtype", '');
+                $sendtype = Db::name("purchease_order")->alias("a")
+                ->leftJoin("purchease_in b", "a.cgdNo=b.cgdNo")
+                ->where(["bkcode" => $value['发货方式'], "order_type" => 1,"order_source"=>0])
+                ->order("b.addtime desc")->value("b.sendtype", '');
                 $value['是否库存品'] = '是';
             } else {
                 $sendtype = Db::name("purchease_order")->alias("a")->leftJoin("purchease_in b", "a.cgdNo=b.cgdNo")->where(["a.cgdNo" => $value['发货方式']])->order("b.addtime desc")->value("b.sendtype", '');
@@ -743,7 +746,7 @@ class NowReportHandle extends Command
             ->leftJoin("good_basic wgb", "wgb.spuCode=wpo.spuCode and wgb.is_del=0")
             ->leftJoin("supplier ws", "ws.code=wpo.supplierNo")
             ->leftJoin("warehouse_info wwi", "wwi.wsm_code = wpo.wsm_code")
-            ->where([['woo.status', ">=", 2],['woo.is_del',"=", 0],['a.order_type', "=", 1],['woo.addtime','between',[$start, $end]]])
+            ->where([['woo.status', ">=", 2],['woo.is_del',"=", 0],['a.order_type', "=", 1],['woo.sendtime','between',[$start, $end]]])
             ->field("wpo.companyNo '业务公司',bkcode '备库单号',woo.orderCode '销售单号',woo.outCode '出库单号',wpo.cgdNo '采购单号',wpo.spuCode '商品编号','' as '一级分类','' as '二级分类',wgb.cat_id as '三级分类',wpo.good_name as '商品名称',woo.send_num'出库数量',woo.sendtime '本次出库时间',a.apply_id as '业务部门',a.apply_name as '业务员',wpo.cgder as '采购员',wor.return_num  '出库退货数量',wwi.wsm_type '仓库类型',ws.name '供应商名称',wwi.name '仓库名称'")
             ->cursor();
         $data = [];