|
@@ -166,24 +166,30 @@ class NowReportHandle extends Command
|
|
|
{
|
|
|
$data = Db::name('good_stock')
|
|
|
->alias('wgs')
|
|
|
- ->field(" wb.company '公司名称',
|
|
|
- wgs.spuCode '产品编号',
|
|
|
- cat_id '一级分类',
|
|
|
- good_name '产品名称',
|
|
|
- '' as '成本单价',
|
|
|
- wait_in_stock '待入库存数量',
|
|
|
- wait_out_stock '待出库存数量',
|
|
|
- usable_stock '可用库存数量',
|
|
|
- wait_out_stock+usable_stock '当前库存',
|
|
|
- '' as '可用库存金额',
|
|
|
- '' as '当前库存金额',
|
|
|
- '' as '保质期时间',
|
|
|
- '' as '库存天数',
|
|
|
- wgb.creater as 'CGD.采购员',
|
|
|
- '' as '备库单号',
|
|
|
- ws.`name` as '供应商名称',
|
|
|
- wwi.`name` as '仓库名称',
|
|
|
- '' as '最近入库时间'")
|
|
|
+ ->field(" wb.company '公司名称',
|
|
|
+ wpo.bkcode as '备库单号',
|
|
|
+ wpo.cgdNo as '采购单号',
|
|
|
+ wp.apply_id as '申请部门',
|
|
|
+ wp.apply_name as '申请人',
|
|
|
+ cat_id '一级分类',
|
|
|
+ wgb.good_name '产品名称',
|
|
|
+ wp.good_num '备库数量',
|
|
|
+ wgs.spuCode '产品编号',
|
|
|
+ wpo.good_price as '成本单价',
|
|
|
+ wait_in_stock '待入库存数量',
|
|
|
+ wait_out_stock '待出库存数量',
|
|
|
+ usable_stock '可用库存数量',
|
|
|
+ wait_out_stock+usable_stock '当前库存',
|
|
|
+ '' as '可用库存金额',
|
|
|
+ '' as '当前库存金额',
|
|
|
+ '' as '保质期时间',
|
|
|
+ '' as '库存天数',
|
|
|
+ wgb.creater as 'CGD.采购员',
|
|
|
+ ws.`name` as '供应商名称',
|
|
|
+ wwi.`name` as '仓库名称',
|
|
|
+ '' as '最近入库时间' ")
|
|
|
+ ->leftJoin('purchease_order wpo', 'wgs.spuCode = wpo.spuCode and order_source=0')
|
|
|
+ ->leftJoin('purchease wp', 'wp.bk_code = wpo.bkcode')
|
|
|
->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')
|
|
@@ -198,16 +204,10 @@ class NowReportHandle extends Command
|
|
|
foreach ($data as $value) {
|
|
|
$cat = made($value['一级分类']);
|
|
|
$value['一级分类'] = isset($cat[0]['name'])?$cat[0]['name']:"";
|
|
|
- $value['成本单价'] = Db::name('good_nake')
|
|
|
- ->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,"order_source"=>0,"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_source"=>0])->order("a.addtime desc")->value("a.bkcode","");
|
|
|
+ $value['产品编号'],"order_type"=>1,"order_source"=>0,"c.status"=>[4,6]])->order("a.addtime desc")->value("c.addtime","");
|
|
|
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天之后
|