public function getAllSkuListByOrderId($orderid, $where = '', $tag = 1) { $sql = "select * from wh_shipping_orderdetail where shipOrderId={$orderid} {$where}"; $query = $this->dbconn->query($sql); $lists = $this->dbconn->fetch_array_all($query); $return_result = array(); $result = array(); $totalnum = 0; $package_type = ''; foreach ($lists as $list) { $skuinfo = OmAvailableModel::getTNameList("pc_goods", "goodsCategory,isPacking", "where sku='{$list['sku']}'"); if ($tag == 1) { $catename = SkuStockModel::getCategoryInfoByPath($skuinfo[0]['goodsCategory']); } else { $catename = ''; } $isPacking = $skuinfo[0]['isPacking'] == 2 ? 'Y ' : 'N '; $iscombine = empty($list['combineSku']) ? 0 : 1; if ($iscombine) { $result[$list['combineSku']]['iscombine'] = $iscombine; $result[$list['combineSku']]['info'][] = $isPacking . '[' . $list['pName'] . '] ' . $list['sku'] . '*' . $list['amount'] . $catename; } else { $result['notcombine']['iscombine'] = $iscombine; $result['notcombine']['info'][] = $isPacking . '[' . $list['pName'] . '] ' . $list['sku'] . '*' . $list['amount'] . $catename; } $totalnum += $list['amount']; $package_type = $list['packageType']; } $return_result = array('skuinfo' => $result, 'totalnum' => $totalnum, 'packagetype' => $package_type); return $return_result; }
public function view_getskuStockList() { $type = isset($_GET['type']) ? $_GET['type'] : ''; $searchContent = isset($_GET['searchContent']) ? $_GET['searchContent'] : ''; $online = isset($_GET['online']) ? $_GET['online'] : ''; $warehouse = isset($_GET['warehouse']) ? $_GET['warehouse'] : ''; $isnew = isset($_GET['isnew']) ? $_GET['isnew'] : ''; $pid_one = isset($_GET['pid_one']) ? $_GET['pid_one'] : ''; $pid_two = isset($_GET['pid_two']) ? $_GET['pid_two'] : ''; $pid_three = isset($_GET['pid_three']) ? $_GET['pid_three'] : ''; $pid_four = isset($_GET['pid_four']) ? $_GET['pid_four'] : ''; $skuStockAct = new SkuStockAct(); $where = 'WHERE a.is_delete=0 '; if (!empty($online)) { $where .= "AND a.goodsStatus='{$online}' "; $this->smarty->assign('online', $online); } if (!empty($warehouse)) { $where .= "AND b.storeId='{$warehouse}' "; $this->smarty->assign('warehouse', $warehouse); } if (is_numeric($isnew)) { $where .= "AND a.isNew='{$isnew}' "; $this->smarty->assign('isnew', $isnew); } if (!empty($pid_four)) { $cate = $pid_one . "-" . $pid_two . "-" . $pid_three . "-" . $pid_four; $where .= "AND a.goodsCategory='{$cate}' "; $this->smarty->assign('pid_four', $pid_four); $this->smarty->assign('pid_three', $pid_three); $this->smarty->assign('pid_two', $pid_two); $this->smarty->assign('pid_one', $pid_one); $cate_four = $skuStockAct->act_getCategoryInfo($pid_three); $this->smarty->assign('cate_four', $cate_four); $cate_three = $skuStockAct->act_getCategoryInfo($pid_two); $this->smarty->assign('cate_three', $cate_three); $cate_two = $skuStockAct->act_getCategoryInfo($pid_one); $this->smarty->assign('cate_two', $cate_two); } else { if (!empty($pid_three)) { $cate = $pid_one . "-" . $pid_two . "-" . $pid_three; $where .= "AND a.goodsCategory='{$cate}' "; $this->smarty->assign('pid_three', $pid_three); $this->smarty->assign('pid_two', $pid_two); $this->smarty->assign('pid_one', $pid_one); $cate_three = $skuStockAct->act_getCategoryInfo($pid_two); $this->smarty->assign('cate_three', $cate_three); $cate_two = $skuStockAct->act_getCategoryInfo($pid_one); $this->smarty->assign('cate_two', $cate_two); } else { if (!empty($pid_two)) { $cate = $pid_one . "-" . $pid_two; $where .= "AND a.goodsCategory='{$cate}' "; $this->smarty->assign('pid_two', $pid_two); $this->smarty->assign('pid_one', $pid_one); $cate_two = $skuStockAct->act_getCategoryInfo($pid_one); $this->smarty->assign('cate_two', $cate_two); } else { if (!empty($pid_one)) { $where .= "AND a.goodsCategory='{$pid_one}' "; $this->smarty->assign('pid_one', $pid_one); } } } } switch ($type) { case '1': $spuinfo = OmAvailableModel::getTNameList("pc_goods", "sku", "where spu='{$searchContent}'"); if (empty($spuinfo)) { $skuinfo = get_realskuinfo($searchContent); foreach ($skuinfo as $sku => $num) { $sku_str .= "'" . $sku . "',"; } $sku_str = trim($sku_str, ','); $where .= "AND a.sku in (" . $sku_str . ") "; } else { foreach ($spuinfo as $info) { $sku_str .= "'" . $info['sku'] . "',"; } $sku_str = trim($sku_str, ','); $where .= "AND a.sku in (" . $sku_str . ") "; } break; case '2': $positionIds = SkuStockModel::getAllPositionIdByPName($searchContent); $pos = ''; if (!empty($positionIds)) { foreach ($positionIds as $positionId) { $pos .= $positionId['id'] . ","; } } else { $pos = 0; } $pos = trim($pos, ','); $where .= "AND b.positionId in({$pos}) "; break; case '3': $where .= "AND a.goodsName='{$searchContent}' "; break; case '4': $purchaseId = getUserIdByName($searchContent); if (empty($purchaseId)) { $purchaseId = 10000000; } $where .= "AND a.purchaseId='{$purchaseId}' "; break; case '5': $str = ''; $Supplier_id = CommonModel::getPartnerByName($searchContent); $paramArr['method'] = 'pc.getSkuByPartnerId'; //API名称 $paramArr['pid'] = $Supplier_id; $Supplier_info = UserCacheModel::callOpenSystem($paramArr); if (!empty($Supplier_info['data'])) { foreach ($Supplier_info['data'] as $info) { $str .= "'" . $info . "',"; } $str = trim($str, ","); $str = "(" . $str . ")"; } else { $str = "('no')"; } $where .= "AND a.sku in {$str} "; break; default: break; } $where .= "GROUP BY a.sku "; $total = $skuStockAct->act_getSkuStockCount($where); $num = 100; //每页显示的个数 $page = new Page($total, $num, '', 'CN'); $where .= "ORDER BY a.sku " . $page->limit; $skuStockList = $skuStockAct->act_getSkuStockList($where); if (!empty($_GET['page'])) { if (intval($_GET['page']) <= 1 || intval($_GET['page']) > ceil($total / $num)) { $n = 1; } else { $n = (intval($_GET['page']) - 1) * $num + 1; } } else { $n = 1; } if ($total > $num) { //输出分页显示 $show_page = $page->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $show_page = $page->fpage(array(0, 2, 3)); } $navlist = array(array('url' => 'index.php?mod=skuStock&act=searchSku', 'title' => '库存管理'), array('url' => 'index.php?mod=skuStock&act=searchSku', 'title' => '货品搜索')); $usermodel = UserModel::getInstance(); $count = count($skuStockList); for ($i = 0; $i < $count; $i++) { //$skuStockList[$i]['category'] = CommonModel::getCateInfoByPath($skuStockList[$i]['goodsCategory']); //类别 $user_info = $usermodel->getGlobalUserLists('global_user_name', "where a.global_user_id='{$skuStockList[$i]['purchaseId']}'", '', 'limit 1'); $skuStockList[$i]['pName'] = $user_info[0]['global_user_name']; //类别 $skuStockList[$i]['cateName'] = SkuStockModel::getCategoryInfoByPath($skuStockList[$i]['goodsCategory']); //获取供应商 $par['method'] = 'pc.getPartnerIdBySku'; //API名称 $par['sku'] = $skuStockList[$i]['sku']; $sku_pname = UserCacheModel::callOpenSystem($par); if (!empty($sku_pname['data'])) { $purchase = CommonModel::getPartnerByID($sku_pname['data']); $skuStockList[$i]['PartnerName'] = $purchase['username']; } //仓库 if (!empty($skuStockList[$i]['storeId'])) { $whName_info = WarehouseManagementModel::warehouseManagementModelList("where companyId=1 and id={$skuStockList[$i]['storeId']}"); $skuStockList[$i]['whName'] = $whName_info[0]['whName']; } //图片 //$picUrl = getPicFromOpenSys($skuStockList[$i]['sku']); //$skuStockList[$i]['picUrl'] = $picUrl; } //仓库 $whName = WarehouseManagementModel::warehouseManagementModelList("where companyId=1"); $this->smarty->assign('whName', $whName); //类别 $cate_f = SkuStockModel::getCategoryInfo(0); $this->smarty->assign('cate_f', $cate_f); $this->smarty->assign('type', $type); $this->smarty->assign('searchContent', $searchContent); $this->smarty->assign('navlist', $navlist); $this->smarty->assign('toptitle', '库存信息列表'); $this->smarty->assign('toplevel', 0); $this->smarty->assign('secondlevel', '01'); $this->smarty->assign('show_page', $show_page); $this->smarty->assign('status', $status); $this->smarty->assign('skuStockList', $skuStockList ? $skuStockList : null); //循环列表 $this->smarty->display("skuStock.htm"); }
function act_getActualStockBySS() { $sku = isset($_GET['sku']) ? $_GET['sku'] : ''; //sku $storeId = isset($_GET['storeId']) ? $_GET['storeId'] : 1; //订单记录id if (empty($sku)) { self::$errCode = 1; self::$errMsg = 'empty sku'; return 0; } $tName = 'wh_sku_location'; $select = 'actualStock'; $where = "WHERE sku='{$sku}' AND storeId='{$storeId}'"; $whActualStockList = SkuStockModel::getTNameList($tName, $select, $where); if (empty($whShipOrderIdList)) { //未找到originOrderId对应的shipOrderId self::$errCode = 2; self::$errMsg = 'empty whActualStockList'; return 0; } $actualStock = $whShipOrderIdList[0]['actualStock']; self::$errCode = 200; self::$errMsg = 'success'; return $actualStock; }
/** *获取分类信息 */ public static function getCategoryInfoByPath($path) { self::initDB(); $sql = "select * from pc_goods_category where path='{$path}'"; //echo $sql.'<br>'; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array_all($query); return $ret[0]['name']; //成功, 返回列表数据 } else { self::$errCode = "003"; self::$errMsg = "error"; return false; //失败则设置错误码和错误信息, 返回false } }