|
@@ -51,6 +51,11 @@ class NowReportHandle extends Command
|
|
|
$res = $this->C($info['start'], $info['end']);
|
|
|
break;
|
|
|
|
|
|
+ //
|
|
|
+ case 'D':
|
|
|
+ $res = $this->C($info['start'], $info['end']);
|
|
|
+ break;
|
|
|
+
|
|
|
default:
|
|
|
throw new Exception('暂不支持这个报表');
|
|
|
}
|
|
@@ -247,5 +252,74 @@ class NowReportHandle extends Command
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public function D($start,$end){
|
|
|
+ $list =Db::name("order_out")->alias('woo')->leftJoin("sale a","a.orderCode=woo.orderCode")
|
|
|
+ ->leftJoin("order_back wor","wor.outCode=woo.outCode and status=4")
|
|
|
+ ->leftJoin("order_num won","won.orderCode=a.orderCode")
|
|
|
+ ->leftJoin("purchease_order wpo","wpo.cgdNo=won.cgdNo")
|
|
|
+ ->leftJoin("good_basic wgb","wgb.spuCode=wpo.spuCode")
|
|
|
+ ->leftJoin("good_zixun wgz","wgz.spuCode=wpo.spuCode")
|
|
|
+ ->leftJoin("supplier ws","ws.code=wpo.supplierNo")
|
|
|
+ ->where('woo.status',">=", 2)
|
|
|
+ ->whereBetween('woo.addtime', [$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 `下单数量`,
|
|
|
+ `a`.`total_price` AS `销售货款`,
|
|
|
+ `wpo`.`cgdNo` AS `采购单单号`,
|
|
|
+ `wpo`.`cgder` AS `采购员`,
|
|
|
+ `wpo`.`nake_fee` AS `采购裸价`,
|
|
|
+ `wpo`.`mark_fee` AS `加标费`,
|
|
|
+ `wpo`.`pakge_fee` AS `包装费`,
|
|
|
+ `wpo`.`cert_fee` AS `证书费`,
|
|
|
+ `wpo`.`open_fee` AS `开模费`,
|
|
|
+ `wpo`.`teach_fee` AS `工艺费`,
|
|
|
+ `wpo`.`delivery_fee` AS `物流费`,
|
|
|
+ `wpo`.`good_price` AS `成本合计`,
|
|
|
+ `wpo`.`total_fee` AS `采购货款`,
|
|
|
+ ifnull( `wgb`.`tax`, `wgz`.`tax` ) 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 `退货数量`,
|
|
|
+ round(( ifnull( `wor`.`return_num`, 0 ) * `a`.`sale_price` ), 2 ) as '退货金额',
|
|
|
+ '' as '售前退货数量',
|
|
|
+ `a`.`sale_price` as '售前退货金额'
|
|
|
+ ")->cursor();
|
|
|
+ $order_tyepe=["库存销售",'非库存销售','咨询销售','项目销售','平台库存销售','平台非库存销售'];
|
|
|
+ $good_type=["常规商品",'赠品','样品'];
|
|
|
+ foreach($list as $value){
|
|
|
+ $value['公司名称'] = Db::name("business")->where(["companyNo"=>$value['公司名称']])->value('company','');
|
|
|
+ $value['业务部门名称'] = Db::name("depart_user")->alias("a")->leftJoin("company_item ci","a.itemid=ci.id")
|
|
|
+ ->where(["a.uid"=>$value['业务部门名称'],"status"=>1,"is_del"=>0])->value('ci.name','');
|
|
|
+ $value['订单类型'] = $order_tyepe[ $value['订单类型']-1];
|
|
|
+ $value['商品类型'] = $good_type[ $value['商品类型']-1];
|
|
|
+ $cat =made($value['三级分类']);
|
|
|
+ $value['财务核算编码'] =Db::name("cat")->where(["id"=>$value['三级分类']])->value("fund_code",'');
|
|
|
+ $value['一级分类']=isset($cat[0]['name'])?$cat[0]['name']:"";
|
|
|
+ $value['二级分类']=isset($cat[1]['name'])?$cat[1]['name']:"";
|
|
|
+ $value['三级分类']=isset($cat[2]['name'])?$cat[2]['name']:"";
|
|
|
+ $value['单位']=Db::name("unit")->where(["id"=>$value['单位']])->value("unit",'');
|
|
|
+ if($value['is_stock']==1){
|
|
|
+ $sendtype = Db::name("purchease_order")->alias("a")->leftJoin("purchease_in b","a.cgdNo=b.cgdNo")
|
|
|
+ ->where(["bkcode"=>$value['发货方式'],"order_type"=>[1,5]])->order("b.addtime desc")->value("b
|
|
|
+ .sendtype",'');
|
|
|
+ }else{
|
|
|
+ $sendtype = Db::name("purchease_order")->alias("a")->leftJoin("purchease_in b","a.cgdNo=b.cgdNo")
|
|
|
+ ->where(["cgdNo"=>$value['发货方式']])->order("b.addtime desc")->value("b.sendtype",'');
|
|
|
+ }
|
|
|
+ $value['发货方式'] = $sendtype=1 ? '包邮':$sendtype=2 ? '自提':"";
|
|
|
+ $value['售前退货数量'] = Db::name("sale_return")->where(["orderCode"=>$value['确认单编号']])->sum('num');
|
|
|
+ $value['售前退货金额'] =round($value['售前退货数量']* $value['售前退货金额'],2);
|
|
|
+ yield $list[] = $value;
|
|
|
+ }
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
|
|
|
}
|