|
@@ -168,25 +168,26 @@ class NowReportHandle extends Command
|
|
|
->leftJoin('warehouse_info wwi', 'wwi.wsm_code = wgs.wsm_code')
|
|
|
->leftJoin('business wb', 'wb.companyNo = wwi.companyNo')
|
|
|
->leftJoin('good_basic wgb', 'wgb.spuCode = wgs.spuCode')
|
|
|
- ->leftJoin('supplier ws', 'ws.supplierNo = ws.`code`')
|
|
|
+ ->leftJoin('supplier ws', 'wwi.supplierNo = ws.`code`')
|
|
|
->where('wgs.is_del', 0)
|
|
|
->where('wgb.is_stock', 1)
|
|
|
- ->whereBetween('gs.addtime', [$start_date, $end_date])
|
|
|
+ ->whereBetween('wgs.addtime', [$start_date, $end_date])
|
|
|
->order('wgs.addtime', 'desc')
|
|
|
->cursor();
|
|
|
|
|
|
$list = [];
|
|
|
foreach ($data as $value) {
|
|
|
$cat = made($value['一级分类']);
|
|
|
- $value['一级分类'] = isset($cat[0]['cat_name'])?$cat[0]['cat_name']:"";
|
|
|
+ $value['一级分类'] = isset($cat[0]['name'])?$cat[0]['name']:"";
|
|
|
$value['成本单价'] = Db::name('good_nake')
|
|
|
- ->where('spuCode', $value['产品编码'])
|
|
|
+ ->where('spuCode', $value['产品编号'])
|
|
|
->order('min_num', 'asc')
|
|
|
->value('nake_total', '0');
|
|
|
$value['可用库存金额'] = bcmul((string)$value['可用库存数量'] ?? '0', (string)$value['成本单价'] ?? '0', 2);
|
|
|
$value['当前库存金额'] = bcmul((string)$value['当前库存'] ?? '0', (string)$value['成本单价'] ?? '0', 2);
|
|
|
$value['最近入库时间'] =Db::name("purchease_order")->alias("a")->leftJoin("purchease_in c","a.cgdNo=c.cgdNo")->where(["spuCode"=>
|
|
|
- $value['产品编码'],"order_type"=>1,"c.status"=>[4,6]])->order("c.addtime desc")->value("c.addtime","");
|
|
|
+ $value['产品编号'],"order_type"=>1,"c.status"=>[4,6]])->order("a.addtime desc")->value("c.addtime","");
|
|
|
+ $value['备库单号']=Db::name("purchease_order")->alias("a")->where(["spuCode"=>$value['产品编号'], "order_type"=>1])->order("a.addtime desc")->value("a.bkcode","");
|
|
|
if (!empty($value['最近入库时间'])) {
|
|
|
$value['保质期时间'] = date('Y-m-d H:i:s', strtotime($value['最近入库时间']) + 31536000);//365天之后
|
|
|
$value['库存天数'] = bcdiv((string)(time() - strtotime($value['最近入库时间'])), (string)(24 * 3600));//365天之后
|
|
@@ -209,16 +210,16 @@ class NowReportHandle extends Command
|
|
|
->leftJoin('business wb', ' ws.supplierNo=wb.companyNo')
|
|
|
->leftJoin('order_num won', 'won.orderCode=wtd.orderCode')
|
|
|
->leftJoin('purchease_order wpo', 'wpo.cgdNo=won.cgdNo')
|
|
|
- ->leftJoin('supplier wsp', 'wsp.`code`=wpo.supplierNo')
|
|
|
- ->leftJoin('business wb', 'ws.supplierNo=wb.companyNo')
|
|
|
+ ->leftJoin('supplier wps', 'wps.code=wpo.supplierNo')
|
|
|
->leftJoin('customer_info wci', 'wci.companyNo =ws.customer_code')
|
|
|
- ->whereBetween('ob.addtime', [$start_date, $end_date])
|
|
|
- ->field(" year(ifnull(wsr.addtime,wor.addtime)) '年',
|
|
|
- month(ifnull(wsr.addtime,wor.addtime)) '月',
|
|
|
- DAYOFMONTH(ifnull(wsr.addtime,wor.addtime)) '日',
|
|
|
- ifnull(wsr.addtime,wor.addtime) '退货单创建时间',
|
|
|
+ ->whereBetween('wtd.addtime', [$start_date, $end_date])
|
|
|
+ ->field(" year(wtd.addtime) '年',
|
|
|
+ month(wtd.addtime) '月',
|
|
|
+ DAYOFMONTH(wtd.addtime) '日',
|
|
|
+ wtd.addtime '退货单创建时间',
|
|
|
wb.company '公司名称',
|
|
|
thCode '退货单号',
|
|
|
+ if(wtd.th_type=1,'售前','售后') '退货类型',
|
|
|
'已完成' as '流程进度',
|
|
|
wtd.apply_id '业务部门',
|
|
|
wtd.apply_name '业务人员',
|
|
@@ -226,7 +227,7 @@ class NowReportHandle extends Command
|
|
|
ws.platform_id '平台类型',
|
|
|
ws.platform_order '平台订单号',
|
|
|
'' as '客户属性',
|
|
|
- '' as '分公司',
|
|
|
+ wci.itemid as '分公司',
|
|
|
wci.companyName '客户名称',
|
|
|
wtd.spuCode '产品编码',
|
|
|
'' as '财务核算码',
|
|
@@ -238,7 +239,7 @@ class NowReportHandle extends Command
|
|
|
wtd.th_num '退货数量',
|
|
|
ws.sale_price '销售单价',
|
|
|
wtd.th_fee '退货金额',
|
|
|
- '' as '退货备注',
|
|
|
+ ifnull(wsr.remark,wor.error_remark) as '退货备注',
|
|
|
won.cgdNo '采购单单号',
|
|
|
wpo.cgder '采购员',
|
|
|
wpo.nake_fee '采购裸价',
|
|
@@ -255,13 +256,13 @@ class NowReportHandle extends Command
|
|
|
wpo.supplier_name '供应商名称',
|
|
|
if(ws.is_stock=1,'是','否') '是否库存',
|
|
|
'' as '发货方式',
|
|
|
- if(wsp.pay_type='0','现结',if(wsp.pay_type='1','月清',if(wsp.pay_type='2','双月请',wsp.pay_type))) as '付款方式'")
|
|
|
- ->cursor();
|
|
|
+ if(wps.pay_type='0','现结',if(wps.pay_type='1','月结',if(wps.pay_type='2','双月结',wps.pay_type))) as '付款方式'
|
|
|
+
|
|
|
+ ")->cursor();
|
|
|
|
|
|
- $list = [];
|
|
|
+ $com = [];
|
|
|
foreach ($data as $value) {
|
|
|
-
|
|
|
- $value['业务部门'] = get_company_name_by_uid($value['业务部门']);
|
|
|
+ $value['业务部门'] = get_company_name_by_uid(intval($value['业务部门']));
|
|
|
$value['财务核算码']=Db::name("cat")->where(["id"=>$value['三级分类']])->value("fund_code",'');
|
|
|
$comp =get_top_customer_org($value['分公司']);
|
|
|
$value['客户属性']=isset($comp[0]['name'])?$comp[0]['name']:"";
|
|
@@ -275,13 +276,13 @@ class NowReportHandle extends Command
|
|
|
}else{
|
|
|
$good= Db::name("good_basic")->where(["spuCode"=>$value['产品编码']])->find();
|
|
|
}
|
|
|
- $value['单位']=isset($good['good_unit'])?Db::name("unit")->where(["id"=>$value['good_unit']])->value('unit',''):"";
|
|
|
- $value['税率']=isset($good['tax'])?$good['tax'].'%':"";
|
|
|
+ $value['单位']=isset($good['good_unit'])?Db::name("unit")->where(["id"=>$good['good_unit']])->value('unit',''):"";
|
|
|
+ $value['税点']=isset($good['tax'])?$good['tax'].'%':"";
|
|
|
$value['平台类型']= Db::name("platform")->where(["id"=>$value['平台类型']])->value("platform_name",'');
|
|
|
- yield $list[] = $value;
|
|
|
+ yield $com[] = $value;
|
|
|
}
|
|
|
|
|
|
- return $list;
|
|
|
+ return $com;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -442,6 +443,7 @@ class NowReportHandle extends Command
|
|
|
bkcode '备库单号',
|
|
|
woo.orderCode '销售单号',
|
|
|
woo.outCode '出库单号',
|
|
|
+ wpo.cgdNo '采购单号',
|
|
|
wpo.spuCode '商品编号',
|
|
|
'' as '一级分类',
|
|
|
'' as '二级分类',
|