Files
OMS/app/purchase/lib/finder/goods.php
2025-12-28 23:13:25 +08:00

60 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
class purchase_finder_goods{
var $detail_goods_price = "供应商价格";
function detail_goods_price($goods_id){
$render = app::get('purchase')->render();
if(!is_numeric($goods_id)) die('访问出错');
//根据商品ID获取供应商列表
$sql = ' SELECT a.name,a.supplier_id FROM `sdb_purchase_supplier` a
LEFT JOIN `sdb_purchase_supplier_goods` b ON a.supplier_id=b.supplier_id
WHERE b.bm_id='.$goods_id;
$row = kernel::database()->select($sql);
unset($sql);
$basicMaterialSelect = kernel::single('material_basic_select');
$product_id = $basicMaterialSelect->getlist('bm_id', array('bm_id'=>$goods_id));
$product_id_str = implode(',', $product_id);
//获取供应商此件商品的最高价格、历史价格及当前价格
foreach ($row as $k=>$v){
//最高、最低SQL
$sql0 = " SELECT e.`supplier_id` ";
$sql1 = " from `sdb_purchase_branch_product_batch` e
WHERE e.`supplier_id`='".$v['supplier_id']."' and e.`product_id` in (". $product_id_str .")
GROUP BY e.`supplier_id` ";
//当前价格sql
$sqlCurr = " SELECT e.`purchase_price` FROM `sdb_purchase_branch_product_batch` e
WHERE e.`supplier_id`='".$v['supplier_id']."' and e.`product_id` in
(". $product_id_str .") ORDER BY e.`purchase_time` DESC LIMIT 0,1 ";
//最高价格
$highestField = ",max(e.purchase_price) as hight";
$lowerestFild = ",min(e.purchase_price) as lowers ";
$tempsql = $sql0.$highestField.$sql1;
$highestPrice = kernel::database()->select($tempsql);
//最低价格
$tempsql = $sql0.$lowerestFild.$sql1;
$lowerestPrice = kernel::database()->select($tempsql);
//当前价格
$currPrice = kernel::database()->select($sqlCurr);
$v['highestprice'] = $highestPrice[0]['hight'];
$v['lowerestprice'] = $lowerestPrice[0]['lowers'];
$v['currPrice'] = $currPrice[0]['purchase_price'];
$price_list[] = $v;
}
unset($row);
$render->pagedata['supplier_price'] = $price_list;
$render->pagedata['goods_id'] = $goods_id;
return $render->fetch('admin/goods/supplier_price.html');
}
}
?>