public function recordReviewInfo($data) { $orderid = $data['orderid']; $orderdetailid = $data['detailid']; $sku = $data['sku']; $sku = mysql_real_escape_string($sku); $amount = $data['amount']; $totalNums = $data['totalNums']; $time = time(); $userid = $data['userid']; $storeId = $data['storeId']; $islast = $data['islast']; $skuinfo = getSkuInfoBySku($sku); $skuname = empty($skuinfo) ? '' : $skuinfo['goodsName']; $skuname = mysql_real_escape_string($skuname); $insert_sql = "insert into wh_order_review_records values (null, {$orderid}, {$orderdetailid}, '{$sku}', '{$skuname}', \n \t{$amount}, {$totalNums}, {$time}, {$userid}, null, null, 1, 0, {$storeId})"; if ($islast) { //最后一次复核 则更新发货单状态 $updatesql = "update wh_shipping_order set orderStatus=" . PKS_WWEIGHING . ' where id=' . $orderid; } $this->dbconn->begin(); $insertresult = $this->dbconn->query($insert_sql); //插入复核数据 if ($insertresult == FALSE) { //插入数据失败 则回滚 $this->dbconn->rollback(); $this->dbconn->query('SET AUTOCOMMIT=1'); return FALSE; } if ($islast) { $updateresult = $this->dbconn->query($updatesql); if ($updateresult == FALSE) { //更新状态失败 $this->dbconn->rollback(); $this->dbconn->query('SET AUTOCOMMIT=1'); return FALSE; } } $this->dbconn->commit(); return TRUE; }
public function act_export() { $invPeople = isset($_GET['invPeople']) ? $_GET['invPeople'] : ''; $sku = isset($_GET['sku']) ? post_check($_GET['sku']) : ''; $invType = isset($_GET['invType']) ? $_GET['invType'] : ''; $startdate = isset($_GET['startdate']) ? post_check($_GET['startdate']) : ''; $enddate = isset($_GET['enddate']) ? post_check($_GET['enddate']) : ''; $auditStatus = isset($_GET['auditStatus']) ? post_check($_GET['auditStatus']) : ''; if (empty($invPeople) && empty($sku) && empty($invType) && empty($startdate) && empty($enddate) && empty($auditStatus)) { echo "请选择导出条件"; exit; } $where = 'where storeId=1 '; if ($invPeople) { $where .= "and invPeople ='{$invPeople}' "; } if ($sku) { $where .= "and sku ='{$sku}' "; } if ($invType) { $where .= "and invType ='{$invType}' "; } if ($startdate) { $starttime = strtotime($startdate); $where .= "and invTime >='{$starttime}' "; } if ($enddate) { $endtime = strtotime($enddate); $where .= "and invTime <='{$endtime}' "; } if ($auditStatus != '' && $auditStatus != 3) { $where .= "and auditStatus = {$auditStatus}"; } $lists = InvRecordModel::getInvRecordList('*', $where); $excel = new ExportDataExcel('browser', "Files_warehouse" . date('Y-m-d') . ".xls"); $excel->initialize(); $tharr = array("日期", "料号", "仓位", "系统数量", "盘点数量", "差异数量", "料号单价", "类型", "盘点原因", "盘点人", "采购员", "物料管理人", "状态", '备注信息'); $excel->addRow($tharr); foreach ($lists as $list) { $time = date('Y-m-d', $list['invTime']); $sku = $list['sku']; $location = $list['location']; $systemNums = $list['systemNums']; $sku_info = getSkuInfoBySku($list['sku']); $goodsCost = $sku_info['goodsCost']; $invNums = $list['invNums']; if ($list['invType'] == 1) { $num = $list['adjustNums']; $type = "盘盈"; } elseif ($list['invType'] == 2) { $num = '-' . $list['adjustNums']; $type = "盘亏"; } else { $num = $list['adjustNums']; $type = ""; } $remark = $list['remark'] ? $list['remark'] : ''; $reason_info = InvReasonModel::getInvReasonList("reasonName", "where id='{$list['reasonId']}'"); $reason = $reason_info[0]['reasonName']; $invPeople = getUserNameById($list['invPeople']); //$sku_info = getSkuInfoBySku($list['sku']); $purchaseName = $sku_info['purchaseId'] ? getUserNameById($sku_info['purchaseId']) : '无'; $menergeMan = ''; $mark = ''; if ($list['auditStatus'] == 0) { $mark = '未审核'; } else { if ($list['auditStatus'] == 1) { $mark = '通过'; } else { if ($list['auditStatus'] == 2) { $mark = '拒绝'; } } } $tdarr = array($time, $sku, $location, $systemNums, $invNums, $num, $goodsCost, $type, $reason, $invPeople, $purchaseName, $menergeMan, $mark, $remark); $excel->addRow($tdarr); } $excel->finalize(); exit; }
public function view_invList() { $now_time = date("Y-m-d H:i:s", time()); $state = isset($_GET['state']) ? post_check($_GET['state']) : ''; $this->smarty->assign('state', $state); $reason = array(); $invPeople = isset($_GET['invPeople']) ? $_GET['invPeople'] : ''; $sku = isset($_GET['sku']) ? post_check($_GET['sku']) : ''; $invType = isset($_GET['invType']) ? $_GET['invType'] : ''; $auditStatus = isset($_GET['auditStatus']) ? $_GET['auditStatus'] : 3; $startdate = isset($_GET['startdate']) ? post_check($_GET['startdate']) : ''; $enddate = isset($_GET['enddate']) ? post_check($_GET['enddate']) : ''; $InventoryAct = new InventoryAct(); $where = 'where storeId=1 '; if ($invPeople) { $where .= "and invPeople ='{$invPeople}' "; $this->smarty->assign('invPeople', $invPeople); } if ($sku) { $where .= "and sku ='{$sku}' "; $this->smarty->assign('sku', $sku); } if ($invType) { $where .= "and invType ='{$invType}' "; $this->smarty->assign('invType', $invType); } if ($auditStatus != 3) { $where .= "and auditStatus ='{$auditStatus}' "; } $this->smarty->assign('auditStatus', $auditStatus); if ($startdate) { $starttime = strtotime($startdate); $where .= "and invTime >='{$starttime}' "; } else { $startdate = $now_time; } $this->smarty->assign('startdate', $startdate); if ($enddate) { $endtime = strtotime($enddate); $where .= "and invTime <='{$endtime}' "; } else { $enddate = $now_time; } $this->smarty->assign('enddate', $enddate); $total = $InventoryAct->act_getInvNum($where); $num = 80; //每页显示的个数 $page = new Page($total, $num, '', 'CN'); $where .= "order by sku, id " . $page->limit; $inventory_info = $InventoryAct->act_getInvRecordList('*', $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)); } $this->smarty->assign('show_page', $show_page); //盘点原因 if (!empty($inventory_info)) { foreach ($inventory_info as $key => $info) { $reason_info = InvReasonModel::getInvReasonList("reasonName", "where id='{$info['reasonId']}'"); $reason[$info['id']] = $reason_info[0]['reasonName']; $sku_info = getSkuInfoBySku($info['sku']); $inventory_info[$key]['goodsCost'] = $sku_info['goodsCost']; $inventory_info[$key]['purchaseName'] = $sku_info['purchaseId'] ? getUserNameById($sku_info['purchaseId']) : '无'; $inventory_info[$key]['remark'] = $info['remark'] ? $info['remark'] : ''; //新增等待上架数量 add by Gary $tallyList = OmAvailableModel::getTNameList('wh_tallying_list', 'sum(ichibanNums) ichibanNums, sum(shelvesNums) shelvesNums', "where sku='{$info['sku']}' and tallyStatus=0 and is_delete = 0"); $ichibanNums = intval($tallyList[0]['ichibanNums']); $shelvesNums = intval($tallyList[0]['shelvesNums']); $inventory_info[$key]['wait_whself'] = $ichibanNums - $shelvesNums; } } $usermodel = UserModel::getInstance(); //盘点员 $iqc_user = $usermodel->getGlobalUserLists('global_user_id,global_user_name', "where a.global_user_job in(162,165)", '', ''); $this->smarty->assign('iqc_user', $iqc_user); $this->smarty->assign('inventory_info', $inventory_info ? $inventory_info : array()); $this->smarty->assign('reason', $reason); $navlist = array(array('url' => 'index.php?mod=skuStock&act=getSkuStockList', 'title' => '仓库'), array('url' => 'index.php?mod=inventory&act=inventory', 'title' => '盘点管理'), array('url' => 'index.php?mod=inventory&act=invList', 'title' => '盘点列表')); $toplevel = 0; //一级菜单的序号 0 开始 $this->smarty->assign('toplevel', $toplevel); $secondlevel = 04; //当前的二级菜单 $this->smarty->assign('secondlevel', $secondlevel); $this->smarty->assign('navlist', $navlist); $this->smarty->assign('toptitle', '盘点列表'); $this->smarty->assign('curusername', $_SESSION['userName']); $this->smarty->display('inventoryInfo.htm'); }
private function handelScanSubmit($ordertype) { $sku = isset($_POST['sku']) ? trim($_POST['sku']) : 0; //sku $sku = get_goodsSn($sku); if (empty($sku)) { self::$errCode = 0; self::$errMsg = '请输入sku'; return FALSE; } $orderid = isset($_POST['orderid']) ? abs(intval($_POST['orderid'])) : 0; //单号 if (empty($orderid)) { self::$errCode = 0; self::$errMsg = '请输入单号!'; return FALSE; } $num = isset($_POST['num']) ? intval($_POST['num']) : 0; //数量 if (!(is_int($num) && $num > 0)) { self::$errCode = 0; self::$errMsg = '请输入正确的数量!'; return FALSE; } $pName = isset($_POST['pname']) ? trim($_POST['pname']) : ''; //仓位 if (empty($pName)) { self::$errCode = 0; self::$errMsg = '仓位有误,请联系it'; return FALSE; } $pcko_obj = new PackingOrderModel(); $orderinfo = $pcko_obj->getOrderInfoById($orderid, ' and orderStatus=' . PKS_WGETGOODS); //发货单完整信息 if (empty($orderinfo)) { //订单号不存在 self::$errCode = 0; self::$errMsg = '订单号不存在!'; return FALSE; } /* 验证该订单的类型是否符合要求 */ if ($ordertype == 1) { //为快递单 if (!ShipingTypeModel::isExpressShiping($orderinfo['transportId'])) { self::$errCode = 0; self::$errMsg = '该订单为非快递单!'; return FALSE; } } elseif ($ordertype == 2) { //为非快递单 if (!ShipingTypeModel::isSmallpressShiping($orderinfo['transportId'])) { self::$errCode = 0; self::$errMsg = '该订单非小包订单!'; return FALSE; } } elseif ($ordertype == 3) { if (!ShipingTypeModel::isInlandShiping($orderinfo['transportId'])) { self::$errCode = 0; self::$errMsg = '该订单非国内快递订单!'; return FALSE; } } /***添加料号、配货数量验证 start ***/ if ($ordertype == 1) { $sod_obj = new ShipingOrderDetailModel(); $rtnNum = $sod_obj->checkOrderSku($orderid, $sku); if ($rtnNum == 0) { self::$errCode = 20; self::$errMsg = '发货单号不存在料号[' . $sku . ']'; return false; } else { $rtnNum = $sod_obj->checkSkuPickRecord($orderid, $sku, $pName); if ($rtnNum != 0) { self::$errCode = 20; self::$errMsg = '料号[' . $sku . ']已配货'; return false; } else { $actualNum = $sod_obj->checkSkuQty($orderid, $sku); $diffNum = $num - $actualNum; if ($diffNum > 0) { self::$errCode = 20; self::$errMsg = '料号[' . $sku . ']需配货' . $actualNum . '件现配' . $num . '件多配' . $diffNum . '件'; return false; } else { if ($diffNum < 0) { self::$errCode = 20; self::$errMsg = '料号[' . $sku . ']需配货' . $actualNum . '件现配' . $num . '件少配-' . $diffNum . '件'; return false; } else { } } } } } /***添加料号、配货数量验证 end ***/ $sod_obj = new ShipingOrderDetailModel(); $skulist = $sod_obj->getSkuListByOrderId($orderid); //该发货单下的全部sku列表 $sku_scaned = $sod_obj->getSkuHavedone($orderid); //该订单下的已配货的sku列表 foreach ($sku_scaned as $skval) { //去掉已配货的 if (array_key_exists($skval['shipOrderdetailId'], $skulist)) { unset($skulist[$skval['shipOrderdetailId']]); } } $matched = null; foreach ($skulist as $val) { if ($val['amount'] == $num && $val['sku'] == $sku) { //找到匹配的 $matched = $val; break; } } $islast = FALSE; if (count($skulist) == 1) { //为最后一个配货料号 $islast = TRUE; } if (empty($matched)) { //没找到数量匹配的 self::$errCode = 0; self::$errMsg = 'sku数量不对!'; return FALSE; } //删除库存 插入配货记录 $data = array('num' => $num, 'sku' => $sku, 'pName' => $pName, 'orderid' => $orderid, 'detailid' => $matched['id'], 'amount' => $num, 'totalnum' => $matched['amount'], 'userid' => $_SESSION['userId'], 'islast' => $islast, 'orderTypeId' => $orderinfo['orderTypeId'], 'shiptype' => $ordertype); $dbresult = $sod_obj->recordDataToSystem($data); if (!$dbresult) { //插入数据失败 self::$errCode = 0; self::$errMsg = '配货失败,请重试!'; return FALSE; } if ($islast) { //最后一个配货完成 // WhPushModel::pushOrderStatus($orderid,'STATESHIPPED_PENDREVIEW',$_SESSION['userId'],time()); //状态推送 self::$errCode = 2; self::$errMsg = '配货成功!'; return TRUE; } else { $skulist = $sod_obj->getSkuListInOneOrder($orderid); $sign = 0; $skulists = array(); foreach ($skulist as $k => $v) { $sku = $v['sku']; $amount = $v['amount']; //配货数量 $posId = $v['positionId']; //仓位ID $pName = $v['pName']; //仓位名称 $storeId = $v['storeId']; //仓库ID,默认1:深圳赛维 $skuInfo = getSkuInfoBySku($sku); //获取料号信息 $skuId = $skuInfo['id']; //料号ID $stockQty = get_SkuStockQty($skuId, $posId, $storeId); //库存数量 $skulists[$sign]['sku'] = $sku; $skulists[$sign]['amount'] = $amount; $skulists[$sign]['pName'] = $pName; $skulists[$sign]['positionId'] = $posId; $skulists[$sign]['stockqty'] = $stockQty; $sign++; } $skulist = $skulists; self::$errCode = 1; self::$errMsg = '配货成功!'; self::$data = $skulist; return TRUE; } }