/** * 测试计划列表 */ public function plist() { //如果caseid不为空,则直接id查询,其他查询条件不生效 $planId = $this->_get('plan_id'); if (!empty($planId)) { $condition['id'] = trim($planId); } else { $desc = $this->_get('plan_desc'); if (!empty($desc)) { $condition['desc'] = array('like', '%' . $desc . '%'); } $owner = $this->_get('owner'); if (!empty($owner)) { $condition['userId'] = getUserIdByName(trim($owner)); } } $new = $this->merge($condition); $page = $this->getPaging('Plan', $new); $paging = $page->show(); $this->assign('paging', $paging); $plans = D('Plan')->where($new)->order('updateTime desc')->limit($page->firstRow . ',' . $page->listRows)->select(); //添加username作为返回信息 foreach ($plans as $plan) { $plan['caseCount'] = count(explode(",", $plan['caseIds'])); $plan['username'] = getUserName($plan['userId']); $data[] = $plan; } $this->assign('plans', $data); $this->display(); }
/** * 测试用例列表 */ public function clist() { //如果caseid不为空,则直接id查询,其他查询条件不生效 $caseId = $this->_get('case_id'); if (!empty($caseId)) { $condition['id'] = trim($caseId); } else { //如果填写了API-ID,则直接根据id进行查询,path查询条件不再生效 $apiId = $this->_get('api_id'); if (!empty($apiId)) { $ids = D('Step')->getCaseIdByKey($apiId, 'id'); $condition['id'] = array('in', $ids); } else { $apiPath = $this->_get('api_path'); if (!empty($apiPath)) { $ids = D('Step')->getCaseIdByKey($apiPath, 'path'); $condition['id'] = array('in', $ids); } } $desc = $this->_get('case_desc'); if (!empty($desc)) { $condition['desc'] = array('like', '%' . $desc . '%'); } $owner = $this->_get('owner'); if (!empty($owner)) { $condition['userId'] = getUserIdByName(trim($owner)); } $type = $this->_get("case_type"); if (!empty($type)) { $condition['type'] = $type; } $mid = $this->_get("mid"); if (!empty($mid)) { $condition['mid'] = intval($mid); } } $new = $this->merge($condition); $page = $this->getPaging('Case', $new); $paging = $page->show(); $this->assign('paging', $paging); $cases = D('Case')->where($new)->order('updateTime desc')->limit($page->firstRow . ',' . $page->listRows)->select(); //添加username作为返回信息 foreach ($cases as $case) { $case['username'] = getUserName($case['userId']); $case['module'] = reset(D("Module")->getModule(array('id' => $case['mid']))); $data[] = $case; } $this->assign('cases', $data); $this->display(); }
function addUser($userName, $passwordHash, $role) { $dbInfo = getDbForUserIdGeneration(); $link = $dbInfo ? connect($dbInfo) : null; if (!$link || !\database\beginTransaction($link)) { return 0; } $userId = \database\getNextUserId($link); if (!$userId) { \database\rollbackTransaction($link); return 0; } $existingId = getUserIdByName($userName); if ($existingId) { \database\rollbackTransaction($link); return 0; } if (!insertUser($userId, $userName, $passwordHash, $role)) { \database\rollbackTransaction($link); return 0; } return \database\commitTransaction($link) ? $userId : 0; }
public function view_getWhIoRecordsList() { $type = isset($_GET['type']) ? $_GET['type'] : ''; $status = isset($_GET['status']) ? $_GET['status'] : ''; $ioType = isset($_GET['ioType']) ? $_GET['ioType'] : ''; if (intval($ioType) != 1 && intval($ioType) != 2) { //1为出库,2为入库 $this->smarty->assign('$toptitle', '出入库记录列表'); $this->smarty->assign('status', '参数错误'); $this->smarty->assign('whIoRecordsList', null); //循环列表 $this->smarty->display("whIoRecords.htm"); } else { $ioType = intval($ioType); $whIoRecordsAct = new WhIoRecordsAct(); $where = "WHERE ioType='{$ioType}' "; if ($type == 'search') { $id = isset($_GET['id']) ? post_check($_GET['id']) : ''; $ordersn = isset($_GET['ordersn']) ? post_check($_GET['ordersn']) : ''; $ioTypeId = isset($_GET['ioTypeId']) ? post_check($_GET['ioTypeId']) : ''; $sku = isset($_GET['sku']) ? post_check($_GET['sku']) : ''; $purchaseId = isset($_GET['purchaseId']) ? post_check($_GET['purchaseId']) : ''; $userId = isset($_GET['userId']) ? post_check($_GET['userId']) : ''; $positionId = isset($_GET['position']) ? post_check($_GET['position']) : ''; $cStartTime = isset($_GET['cStartTime']) ? post_check($_GET['cStartTime']) : ''; $cEndTime = isset($_GET['cEndTime']) ? post_check($_GET['cEndTime']) : ''; if (!empty($id)) { $where .= "AND id='{$id}' "; } if (!empty($ordersn)) { $where .= "AND ordersn='{$ordersn}' "; } if (!empty($ioTypeId)) { $where .= "AND ioTypeId='{$ioTypeId}' "; } if (!empty($sku)) { $where .= "AND sku='{$sku}' "; } if (!empty($purchaseId)) { $purchaseId = getUserIdByName($purchaseId); $where .= "AND purchaseId='{$purchaseId}' "; } if (!empty($userId)) { $userId = getUserIdByName($userId); $where .= "AND userId='{$userId}' "; } if ($positionId) { $positionId = WhPositionDistributionModel::get_position_info('id', '', $positionId); $positionId = empty($positionId) ? '-1' : $positionId[0]['id']; $where .= "AND positionId = '{$positionId}' "; } if (!empty($cStartTime)) { $startTime = strtotime($cStartTime . '00:00:00'); $where .= "AND createdTime >='{$startTime}' "; } if (!empty($cEndTime)) { $endTime = strtotime($cEndTime . '23:59:59'); $where .= "AND createdTime <='{$endTime}' "; } } $total = $whIoRecordsAct->act_getTNameCount('wh_iorecords', $where); $num = 100; //每页显示的个数 $page = new Page($total, $num, '', 'CN'); $where .= "ORDER BY createdTime DESC " . $page->limit; $whIoRecordsList = $whIoRecordsAct->act_getTNameList('wh_iorecords', '*', $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)); } $toptitle = '出库记录列表'; $ioSearchName = '出库类型'; $navlist = array(array('url' => 'index.php?mod=skuStock&act=getSkuStockList', 'title' => '库存信息'), array('url' => '', 'title' => '出库记录列表')); $this->smarty->assign('toplevel', 0); $this->smarty->assign('secondlevel', '34'); $ioTypeList = WhIoStoreModel::getIoTypeListByioType(0); if ($ioType == 2) { $toptitle = '入库记录列表'; $ioSearchName = '入库类型'; $this->smarty->assign('secondlevel', 35); $navlist = array(array('url' => 'index.php?mod=skuStock&act=getSkuStockList', 'title' => '库存信息'), array('url' => '', 'title' => '入库记录列表')); $ioTypeList = WhIoStoreModel::getIoTypeListByioType(1); } $this->smarty->assign('toptitle', $toptitle); $this->smarty->assign('ioSearchName', $ioSearchName); $this->smarty->assign('ioTypeList', $ioTypeList); $this->smarty->assign('navlist', $navlist); $this->smarty->assign('show_page', $show_page); $this->smarty->assign('status', $status); $usermodel = UserModel::getInstance(); foreach ($whIoRecordsList as $key => $val) { $whIoRecordsList[$key]['ioTypeName'] = WhIoStoreModel::getIoTypeNameById($val['ioTypeId']); $whIoRecordsList[$key]['whName'] = WhIoStoreModel::getWhNameById($val['storeId']); $purchase_user_info = $usermodel->getGlobalUserLists('global_user_name', "where a.global_user_id='{$val['purchaseId']}'", '', 'limit 1'); $whIoRecordsList[$key]['purchaseName'] = $purchase_user_info[0]['global_user_name']; //$user_info = $usermodel->getGlobalUserLists('global_user_name',"where a.global_user_id='{$val['userId']}'",'','limit 1'); //$whIoRecordsList[$key]['userName'] = $user_info[0]['global_user_name']; $whIoRecordsList[$key]['userName'] = getUserNameById($val['userId']); $position_info = whShelfModel::selectPosition("where id={$val['positionId']}"); $whIoRecordsList[$key]['pName'] = $position_info[0]['pName']; } $this->smarty->assign('whIoRecordsList', $whIoRecordsList ? $whIoRecordsList : null); //循环列表 $this->smarty->display("whIoRecords.htm"); } }
/**** 更新总库存 *****/ $where = "where sku='{$sku}'"; $info = whShelfModel::updateStoreNum($nums, $where); if (!$info) { $errCode = 412; $errMsg = "更新总库存失败!"; $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, $errMsg, $info, $nums, $where); write_log($log_file, $log_info); OmAvailableModel::rollback(); continue; } write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n"); $user_id = $msg_array['userId']; /**** 插入出入库记录 *****/ $msg_array['positionId'] = $positioninfo[0]['positionId']; $userId = preg_match("/^\\d+\$/", $user_id) ? $user_id : getUserIdByName($msg_array['userId']); $msg_array['userId'] = $userId ? $userId : 0; $msg_array['purchaseId'] = $skuinfo['purchaseId']; //print_r($msg_array);exit; $record = CommonModel::addIoRecores($msg_array); //出库记录 if (!$record) { $errCode = 413; $errMsg = "插入出入库记录失败!"; $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s \r\n", $sku, $date, $errMsg, $record, json_encode($paraArr)); write_log($log_file, $log_info); OmAvailableModel::rollback(); continue; } write_log($log_file, date('Y-m-d H:i:s') . '插入入库记录成功!' . "{$sku}\r\n"); OmAvailableModel::commit();
/** * WhGoodsAssignAct::act_getErpOrders() * 获取ERP推送过来的B仓订单并生成调拨单 * */ public function act_getErpOrders() { //$ids = $_GET['ids'] ? trim($_GET['ids']) : 0; $orderinfo = trim($_GET['orderinfo']) ? json_decode(trim($_GET['orderinfo']), TRUE) : 0; //订单信息 $user = trim($_GET['createUser']) ? trim($_GET['createUser']) : 0; if (!$orderinfo || !$user) { self::$errCode = '001'; self::$errMsg = 'Param is NULL!'; return FALSE; } $outStoreId = 2; $inStoreId = 1; $createUid = getUserIdByName($user); $createUid = $createUid ? $createUid : 0; $ebay_ids = array(); $realSkuInfo = array(); foreach ($orderinfo as $key => $val) { $is_exist = WhGoodsAssignModel::getAssignOrderById($key); //查看该订单是否已有记录 if (empty($is_exist)) { $ebay_ids[] = $key; foreach ($val as $skuinfo) { $sku = $skuinfo['sku']; $num = $skuinfo['ebay_amount']; if (isset($realSkuInfo[$sku])) { $realSkuInfo[$sku] = $realSkuInfo[$sku] + $num; } else { $realSkuInfo[$sku] = $num; } } } } unset($orderinfo); if (empty($ebay_ids)) { self::$errCode = 200; self::$errMsg = '添加成功!'; return true; } $ebay_ids = implode(',', $ebay_ids); //print_r($realSkuInfo);exit; $sku = array_keys($realSkuInfo); $num = array_values($realSkuInfo); $info = self::act_addList($outStoreId, $inStoreId, $createUid, $sku, $num, $ebay_ids); return $info; }
public function act_export() { $ioType = intval($_GET['ioType']); $id = isset($_GET['id']) ? post_check($_GET['id']) : ''; $ordersn = isset($_GET['ordersn']) ? post_check($_GET['ordersn']) : ''; $ioTypeId = isset($_GET['ioTypeId']) ? post_check($_GET['ioTypeId']) : ''; $sku = isset($_GET['sku']) ? post_check($_GET['sku']) : ''; $purchaseId = isset($_GET['purchaseId']) ? post_check($_GET['purchaseId']) : ''; $userId = isset($_GET['userId']) ? post_check($_GET['userId']) : ''; $cStartTime = isset($_GET['cStartTime']) ? post_check($_GET['cStartTime']) : ''; $cEndTime = isset($_GET['cEndTime']) ? post_check($_GET['cEndTime']) : ''; if (empty($id) && empty($ordersn) && empty($ioTypeId) && empty($sku) && empty($purchaseId) && empty($userId) && empty($cStartTime) && empty($cEndTime)) { echo "请选择导出条件"; exit; } $where = "WHERE ioType='{$ioType}' "; if (!empty($id)) { $where .= "AND id='{$id}' "; } if (!empty($ordersn)) { $where .= "AND ordersn='{$ordersn}' "; } if (!empty($ioTypeId)) { $where .= "AND ioTypeId='{$ioTypeId}' "; } if (!empty($sku)) { $where .= "AND sku='{$sku}' "; } if (!empty($purchaseId)) { $purchaseId = getUserIdByName($purchaseId); $where .= "AND purchaseId='{$purchaseId}' "; } if (!empty($userId)) { $userId = getUserIdByName($userId); $where .= "AND userId='{$userId}' "; } if (!empty($cStartTime)) { $startTime = strtotime($cStartTime . '00:00:00'); $where .= "AND createdTime >='{$startTime}' "; } if (!empty($cEndTime)) { $endTime = strtotime($cEndTime . '23:59:59'); $where .= "AND createdTime <='{$endTime}' "; } $lists = WhIoRecordsModel::getTNameList('wh_iorecords', '*', $where); if ($ioType == 1) { $excel = new ExportDataExcel('browser', "out_warehouse." . date('Y-m-d') . ".xls"); } else { $excel = new ExportDataExcel('browser', "in_warehouse." . date('Y-m-d') . ".xls"); } $excel->initialize(); $tharr = array("日期", "料号", "仓位", "数量", "类型", "申请人", "订单号", "备注"); $excel->addRow($tharr); foreach ($lists as $list) { $time = date('Y/m/d', $list['createdTime']); $sku = $list['sku']; $position_info = whShelfModel::selectPosition("where id={$list['positionId']}"); $pName = $position_info[0]['pName']; $num = $list['amount']; $ioTypeName = WhIoStoreModel::getIoTypeNameById($list['ioTypeId']); $user = getUserNameById($list['userId']); $ordersn = $list['ordersn']; $reason = $list['reason']; $tdarr = array($time, $sku, $pName, $num, $ioTypeName, $user, $ordersn, $reason); $excel->addRow($tdarr); } $excel->finalize(); exit; }
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"); }