Ejemplo n.º 1
0
 public function testAction()
 {
     $price_list = new Erp_Model_Warehouse_Pricelist();
     $price = $price_list->getMultiPrice('MPS050004', 'CNY');
     echo '<pre>';
     print_r($price);
     exit;
 }
Ejemplo n.º 2
0
 public function calcBomPrice($recordkey, $currency = 'CNY')
 {
     $low = $high = $average = 0.0;
     $fa = new Product_Model_Fa();
     $son = new Product_Model_Son();
     $price_list = new Erp_Model_Warehouse_Pricelist();
     $data = $this->getJoinList('recordkey = ' . $recordkey);
     // 检查当前BOM是否已有价格
     if (count($data) == 0) {
         // 计算价格
         $sonData = $son->getJoinList("recordkey = " . $recordkey, array(), array('code', 'qty'));
         foreach ($sonData as $sonRow) {
             // 检查是否有BOM数据,如果没有,当作物料处理
             $sonFaData = $fa->getJoinList("code = '" . $sonRow['code'] . "'", array(), array('recordkey'), array('ver desc'));
             if (count($sonFaData) == 0) {
                 if (isset($_SESSION['mprice'][$sonRow['code']])) {
                     // session 中存在
                     $price = $_SESSION['mprice'][$sonRow['code']];
                 } else {
                     $price = $price_list->getMultiPrice($sonRow['code'], $currency);
                     $_SESSION['mprice'][$sonRow['code']] = $price;
                 }
             } else {
                 $price = $this->calcBomPrice($sonFaData[0]['recordkey'], $currency);
             }
             $low += $price['low'] * $sonRow['qty'];
             $high += $price['high'] * $sonRow['qty'];
             $average += $price['average'] * $sonRow['qty'];
         }
     } else {
         $bomPrice = $data[0];
         $low = $bomPrice['low_' . strtolower($currency)];
         $high = $bomPrice['high_' . strtolower($currency)];
         $average = $bomPrice['average_' . strtolower($currency)];
     }
     return array('low' => round($low, 4), 'high' => round($high, 4), 'average' => round($average, 4));
 }
Ejemplo n.º 3
0
 private function getBomInfo($push_data, $fa, $son, $recordkey, $count, $explanded, $rate)
 {
     $price_list = new Erp_Model_Warehouse_Pricelist();
     $bomPrice = new Product_Model_BomPrice();
     $data = $son->getSon($recordkey);
     for ($i = 0; $i < count($data); $i++) {
         $fadata = $fa->getFa($data[$i]['code'], null);
         $faRow = "";
         if ($fadata && count($fadata) > 0) {
             $faRow = $fadata[0];
         }
         $row = array();
         $row['cnt'] = "";
         $row['code'] = $data[$i]['code'];
         if ($faRow) {
             $row['code'] = $data[$i]['code'] . ' V' . $faRow['ver'];
             $row['state'] = $faRow['state'];
             $row['name'] = $data[$i]['name'];
             $row['description'] = $data[$i]['description'];
             $price = $bomPrice->calcBomPrice($faRow['recordkey'], 'CNY');
             $row['low_cny'] = round($price['low'] * $data[$i]['qty'], 4);
             $row['low_usd'] = round($price['low'] * $rate * $data[$i]['qty'], 4);
             $row['high_cny'] = round($price['high'] * $data[$i]['qty'], 4);
             $row['high_usd'] = round($price['high'] * $rate * $data[$i]['qty'], 4);
             $row['average_cny'] = round($price['average'] * $data[$i]['qty'], 4);
             $row['average_usd'] = round($price['average'] * $rate * $data[$i]['qty'], 4);
             $row['project_no_name'] = $faRow['project_no_name'];
             $row['qty'] = $data[$i]['qty'];
             $row['replace'] = $data[$i]['replace'];
             $row['partposition'] = $data[$i]['partposition'];
             $row['remark'] = $data[$i]['remark'];
             $row['count'] = $count;
             $push_data[] = $row;
             if (count($explanded) == 0 || in_array($data[$i]['code'], $explanded)) {
                 $push_data = $this->getBomInfo($push_data, $fa, $son, $faRow['recordkey'], ++$count, $explanded, $rate);
                 $count--;
             }
         } else {
             $row['state'] = $data[$i]['mstate'];
             $row['name'] = $data[$i]['name'];
             $row['description'] = $data[$i]['description'];
             if (isset($_SESSION['mprice'][$data[$i]['code']])) {
                 // session 中存在
                 $price = $_SESSION['mprice'][$data[$i]['code']];
             } else {
                 $price = $price_list->getMultiPrice($data[$i]['code'], 'CNY');
                 $_SESSION['mprice'][$data[$i]['code']] = $price;
             }
             $row['low_cny'] = round($price['low'] * $data[$i]['qty'], 4);
             $row['low_usd'] = round($price['low'] * $rate * $data[$i]['qty'], 4);
             $row['high_cny'] = round($price['high'] * $data[$i]['qty'], 4);
             $row['high_usd'] = round($price['high'] * $rate * $data[$i]['qty'], 4);
             $row['average_cny'] = round($price['average'] * $data[$i]['qty'], 4);
             $row['average_usd'] = round($price['average'] * $rate * $data[$i]['qty'], 4);
             $row['project_no_name'] = "";
             $row['qty'] = $data[$i]['qty'];
             $row['replace'] = $data[$i]['replace'];
             $row['partposition'] = $data[$i]['partposition'];
             $row['remark'] = $data[$i]['remark'];
             $row['count'] = $count;
             $push_data[] = $row;
         }
     }
     return $push_data;
 }