function view_login() { if (!isset($_SESSION['userName'])) { $api = new ApiAct(); $res = $api->act_getAuthCompanyList(); //获取鉴权的公司列表 $this->smarty->assign('lists', $res); $this->smarty->display('login.htm'); } else { //echo C('USER_GO_URL')); redirect_to(C('USER_GO_URL')); } }
/** *功能:API更新QC系统不良品处理 *@param $defectiveId 编号 *@param $infoId 检测记录号 *@param $num 处理数量 *@param $note 备注 *@param $status 状态 1为报废,2为内部处理,3为待退回 *日期:2013/08/12 *作者:王民伟 */ public static function act_updateQcBadGoodData() { $defectiveId = $_GET['defectiveId']; $infoId = $_GET['infoId']; $num = $_GET['num']; $note = $_GET['note']; $status = $_GET['category']; $rtn = ApiAct::update_qcBadGoodData($defectiveId, $infoId, $num, $note, $status); return $rtn; }
/** *功能:处理异常采购订单,例:采购补单、二次录入 *@param $type 处理类型 *@param $dataarray 料号 数量 *@param $purid 采购员编号 *日期:2013/08/05 *作者:王民伟 */ public static function handleUnusualOrder() { $checkPur = UnusualOrderAct::checkPower(); if ($checkPur !== true) { self::$errMsg = '无权限操作'; return false; } $type = $_GET['type']; $dataarray = $_GET['datalist']; $purid = $_GET['purid']; global $dbConn; $errArr = array(); if ($type == 'patchOrder') { //不能重复补单 if (!empty($dataarray)) { $dbConn->begin(); //开启事物 $datalist = explode('@', $dataarray); $datanum = count($datalist); for ($i = 0; $i < $datanum; $i++) { $infolist = explode('*', $datalist[$i]); if (count($infolist) == 3) { $oid = $infolist[0]; $oidlist = "('" . $oid . "')"; $sku = $infolist[1]; $amount = $infolist[2]; $skulist[] = $sku; $rtn_infolist = PurchaseOrderModel::getPurSkuInfo($skulist, $purid); //过滤不是自己负责的SKU,并返回所需数据 unset($skulist); if (empty($rtn_infolist)) { $errArr[] = $sku . '不属于你负责的sku'; } else { //符合条件开始补单 $info_list_num = count($rtn_infolist); for ($i = 0; $i < $info_list_num; $i++) { $detailinfo = array(); $rtn_sku = $rtn_infolist[$i]['sku']; //返回SKU $rtn_partner_id = $rtn_infolist[$i]['partnerid']; //返回供应商编号 $rtn_price = $rtn_infolist[$i]['goodsCost']; //返回采购单价 $isExistPatchOrdersn = PurchaseOrderModel::isExistPatchOrdersn($rtn_partner_id, $purid); //查找条件符合的补单号??? if (empty($isExistPatchOrdersn)) { //不存在符合的补单号 //此次需判断生成订单跟踪号前缀---0:SWB;1:FZ;2:ZG $recordnumber = PurchaseOrderModel::autoCreateOrderSn($purid, 0); //生成采购补单号 $maininfo['recordnumber'] = $recordnumber; //订单号 $maininfo['purchaseuser_id'] = $purid; //采购员编号 $maininfo['partner_id'] = $rtn_partner_id; //供应商编号 $maininfo['company_id'] = 1; //公司编号 $rtn_mainorder = PurchaseOrderModel::insertPatchMainOrder($maininfo); //添加补单主体信息 if ($rtn_mainorder) { //主体添加成功 $detailinfo['sku_id'] = PurchaseOrderModel::getSkuIdBySku($rtn_sku); //根据sku获SKU编号 $detailinfo['price'] = $rtn_price; //采购单价 $detailinfo['count'] = $amount; //补单数量 $detailinfo['sku'] = $sku; //sku $poid = PurchaseOrderModel::getOrderIdByNum($recordnumber); $rtn_detailorder = PurchaseOrderModel::insertPatchDetailOrder($poid, $detailinfo); if ($rtn_detailorder) { $rtn_api = ApiAct::update_unusualOrderSataus($purid, $oidlist, 'patchorder', $recordnumber); //通过API更新状态 if ($rtn_api) { $dbConn->commit(); } else { $dbConn->rollback(); $errArr[] = $sku . '仓库数据修改失败'; } } else { $dbConn->rollback(); $errArr[] = $sku . '详情增加失败'; } } else { $dbConn->rollback(); $errArr[] = $sku . '主订单增加失败'; } //self::$errMsg = 'success'; } else { //存在符合条件的补单号 $detailinfo['sku_id'] = PurchaseOrderModel::getSkuIdBySku($rtn_sku); //根据sku获SKU编号 $detailinfo['price'] = $rtn_price; //采购单价 $detailinfo['count'] = $amount; //补单数量 $detailinfo['sku'] = $sku; //sku $poid = PurchaseOrderModel::getOrderIdByNum($isExistPatchOrdersn); //根据跟踪号取编号 $rtn_detailorder = PurchaseOrderModel::insertPatchDetailOrder($poid, $detailinfo); //添加采购订单明细 if ($rtn_detailorder) { $rtn_api = ApiAct::update_unusualOrderSataus($purid, $oidlist, 'patchorder', $isExistPatchOrdersn); //通过API更新状态 if ($rtn_api) { $dbConn->commit(); } else { $dbConn->rollback(); $errArr[] = $sku . '仓库数据修改失败'; } } else { $dbConn->rollback(); $errArr[] = $sku . '详情增加失败'; } } } } } } } else { $errArr[] = '未传入sku数据'; } if (count($errArr) > 0) { $errStr = implode("<br/>", $errArr); self::$errMsg = $errStr; } else { self::$errCode = "111"; } } else { if ($type == 'secondStockIn') { //二次补录 if (!empty($dataarray)) { $datalist = explode('@', $dataarray); $datanum = count($datalist); for ($i = 0; $i < $datanum; $i++) { $infolist = explode('*', $datalist[$i]); if (count($infolist) == 3) { $oid = $infolist[0]; $oidlist = "('" . $oid . "')"; $sku = $infolist[1]; $amount = $infolist[2]; $skuid = PurchaseOrderModel::getSkuIdBySku($sku); if (empty($skuid)) { $errArr[] = $sku . "不存在库存中"; continue; } $rtnlist = PurchaseOrderModel::checkStockInOrder($skuid); if (!empty($rtnlist)) { //过滤找不到的,不再参与入库操作,否则会继续生成未订单 $rtn = PurchaseOrderAct::act_stockIn($sku, $amount); $rtn_api = ApiAct::update_unusualOrderSataus($purid, $oidlist, 'secondstockin', 'no'); if (!$rtn_api) { $errArr[] = $sku . "数据提交仓库系统失败"; break; } } else { $errArr[] = $sku . "未找到二次录入符合条件"; } } } } else { $errArr[] = "传参有误"; } if (count($errArr) > 0) { self::$errMsg = implode("<br/>", $errArr); return false; } self::$errCode = "111"; return true; } else { if ($type == 'setZero') { if (!empty($dataarray)) { $dataarray_num = count($dataarray); for ($i = 0; $i < $dataarray_num; $i++) { $oidlist .= "'" . $dataarray[$i] . "',"; } $oidlist = "(" . substr($oidlist, 0, strlen($oidlist) - 1) . ")"; $rtn_api = ApiAct::update_unusualOrderSataus($purid, $oidlist, 'setzero', 'no'); $rtn['msg'] = $rtn_api; } else { $rtn['msg'] = 'null'; } return $rtn; exit; } else { if ($type == 'comfirmOrder') { if (!empty($dataarray)) { $dataarray_num = count($dataarray); for ($i = 0; $i < $dataarray_num; $i++) { $oidlist .= "'" . $dataarray[$i] . "',"; } $oidlist = "(" . substr($oidlist, 0, strlen($oidlist) - 1) . ")"; $rtn_api = ApiAct::update_unusualOrderSataus($purid, $oidlist, 'comfirmorder', 'no'); $rtn['msg'] = $rtn_api; } else { $rtn['msg'] = 'null'; } return $rtn; } else { if ($type == 'backOrder') { //订单退货 $dataStr = trim($_GET['dataStr']); $order_type = trim($_GET['order_type']); $dbConn->begin(); if (!empty($dataarray) && !empty($dataStr) && !empty($order_type)) { $dataarray_num = count($dataarray); for ($i = 0; $i < $dataarray_num; $i++) { $oidlist .= "'" . $dataarray[$i] . "',"; } $oidlist = "(" . substr($oidlist, 0, strlen($oidlist) - 1) . ")"; //生成退货订单 $datalist = explode('@', $dataStr); $datanum = count($datalist); for ($i = 0; $i < $datanum; $i++) { $infolist = explode('*', $datalist[$i]); if (count($infolist) == 3) { $oid = $infolist[0]; $oidlist = "('" . $oid . "')"; $sku = $infolist[1]; $amount = $infolist[2]; $skulist[] = $sku; $rtn_infolist = PurchaseOrderModel::getPurSkuInfo($skulist, $purid); //过滤不是自己负责的SKU,并返回所需数据 unset($skulist); if (empty($rtn_infolist)) { $errArr[] = $sku . '不属于你负责的sku'; } else { //符合条件开始补单 $info_list_num = count($rtn_infolist); for ($i = 0; $i < $info_list_num; $i++) { $detailinfo = array(); $rtn_sku = $rtn_infolist[$i]['sku']; //返回SKU $rtn_partner_id = $rtn_infolist[$i]['partnerid']; //返回供应商编号 $rtn_price = $rtn_infolist[$i]['goodsCost']; //返回采购单价 $status_type = " status = 5 AND order_type = {$order_type}"; $isExistPatchOrdersn = PurchaseOrderModel::isExistPatchOrdersn($rtn_partner_id, $purid, $status_type); //查找条件符合的退货单??? if (empty($isExistPatchOrdersn)) { //不存在符合的单号 //此次需判断生成订单跟踪号前缀---0:SWB;1:FZ;2:ZG $recordnumber = PurchaseOrderModel::autoCreateOrderSn($purid, 0); //生成采购补单号 $maininfo['recordnumber'] = $recordnumber; //订单号 $maininfo['purchaseuser_id'] = $purid; //采购员编号 $maininfo['partner_id'] = $rtn_partner_id; //供应商编号 $maininfo['company_id'] = 1; //公司编号 $status = 5; $rtn_mainorder = PurchaseOrderModel::insertPatchMainOrder($maininfo, $status, $order_type); //添加主体信息 if ($rtn_mainorder) { //主体添加成功 $detailinfo['sku_id'] = PurchaseOrderModel::getSkuIdBySku($rtn_sku); //根据sku获SKU编号 $detailinfo['price'] = $rtn_price; //采购单价 $detailinfo['count'] = $amount; //数量 $detailinfo['sku'] = $sku; $poid = PurchaseOrderModel::getOrderIdByNum($recordnumber); $rtn_detailorder = PurchaseOrderModel::insertPatchDetailOrder($poid, $detailinfo); if ($rtn_detailorder) { $rtn_api = ApiAct::update_unusualOrderSataus($purid, $oidlist, 'backorder', 'no'); if ($rtn_api) { $dbConn->commit(); } else { $dbConn->rollback(); $errArr[] = $sku . '仓库数据修改失败'; } } else { $dbConn->rollback(); $errArr[] = $sku . '详情增加失败'; } } else { $dbConn->rollback(); $errArr[] = $sku . '主订单增加失败'; } //self::$errMsg = 'success'; } else { //存在符合条件的补单号 $detailinfo['sku_id'] = PurchaseOrderModel::getSkuIdBySku($rtn_sku); //根据sku获SKU编号 $detailinfo['price'] = $rtn_price; //采购单价 $detailinfo['count'] = $amount; //补单数量 $detailinfo['sku'] = $sku; $poid = PurchaseOrderModel::getOrderIdByNum($isExistPatchOrdersn); //根据跟踪号取编号 $rtn_detailorder = PurchaseOrderModel::insertPatchDetailOrder($poid, $detailinfo); //添加采购订单明细 if ($rtn_detailorder) { $rtn_api = ApiAct::update_unusualOrderSataus($purid, $oidlist, 'backorder', 'no'); if ($rtn_api) { $dbConn->commit(); } else { $dbConn->rollback(); $errArr[] = $sku . '仓库数据修改失败'; } } else { $dbConn->rollback(); $errArr[] = $sku . '详情增加失败'; } } } } } } } else { $errArr[] = "传参有误"; } if (count($errArr) > 0) { self::$errMsg = implode("<br/>", $errArr); return false; } self::$errCode = "111"; return true; } } } } } }
public static function act_getAllPic($spu, $picType) { if (empty($spu)) { $spu = strlen(htmlentities($_REQUEST['spu'], ENT_QUOTES)) > 0 ? htmlentities($_REQUEST['spu'], ENT_QUOTES) : ''; } if (empty($picType)) { $picType = strlen(htmlentities($_REQUEST['picType'], ENT_QUOTES)) > 0 ? htmlentities($_REQUEST['picType'], ENT_QUOTES) : ''; } $errStr = ''; if (empty($spu)) { $errStr .= '料号输入错误!<br />'; } if (empty($picType)) { $errStr .= '站点输入错误!<br />'; } if (strlen($spu) == 1) { $spu = '00' . $spu; } if (strlen($spu) == 2) { $spu = '0' . $spu; } if (!empty($errStr)) { self::$errCode = '001'; self::$errMsg = $errStr; return false; } $paramArr = array('method' => 'datacenter.picture.getAllSizePic', 'format' => 'json', 'v' => '1.0', 'username' => 'purchase', 'spu' => $spu, 'picType' => $picType); $data = callOpenSystem($paramArr); $data = json_decode($data, true); return $data; }
public function view_index() { global $mod, $act; session_start(); $this->smarty->assign('title', '不良品列表'); $this->smarty->assign('mod', $mod); //模块权限 $this->smarty->assign('web_api', WEB_API); //API 接口地址 $timetype = isset($_GET['timetype']) ? $_GET['timetype'] : ''; $starttime = isset($_GET['startTime']) ? $_GET['startTime'] : ''; //,'1354294861'); $endtime = isset($_GET['endTime']) ? $_GET['endTime'] : ''; //,'1375290061'); $sku = isset($_GET['sku']) ? $_GET['sku'] : ''; $purid = isset($_GET['purid']) ? $_GET['purid'] : '1'; $status = isset($_GET['status']) ? $_GET['status'] : ''; $page = isset($_GET['page']) ? $_GET['page'] : '1'; $condition = ''; if (!empty($sku)) { $condition .= " AND sku = '{$sku}'"; } if ($status !== '') { $condition .= " AND defectiveStatus = '{$status}'"; } if ($timetype != 0) { if (!empty($starttime) && $endtime >= $starttime) { $serstart = strpos($starttime, ':') !== false ? strtotime($starttime) : strtotime($starttime . " 00:00:00"); $serend = strpos($endtime, ':') !== false ? strtotime($endtime) : strtotime($endtime . " 23:59:59"); if ($timetype == '1') { $condition .= " AND startTime BETWEEN " . "'{$serstart}'" . " AND " . "'{$serend}'"; } else { if ($timetype == '2') { $condition .= " AND lastModified BETWEEN " . "'{$serstart}'" . " AND " . "'{$serend}'"; } } } } if (empty($condition)) { $condition = ' AND 1 = 1'; } $qc = new ApiAct(); $data = $qc->act_getBadGoodsList(); $data = json_decode($data, true); $data = json_decode($data['data'], true); $list = ''; $pageStr = '暂无数据'; if ($data) { // $totalrow = $data['total']; $data = $data['data']; $spu = ''; $good = new GoodsAct(); //获取采购id $res = commonAct::actGetPurchaseAccess(); $purid = $res['power_ids']; //转换成sku $pur_sku = ApiModel::getSkuByPurids($purid); $pur_sku_arr = array(); foreach ($pur_sku as $pur_sku_val) { $pur_sku_arr[] = $pur_sku_val['sku']; } if (!empty($data)) { foreach ($data as $key => $val) { //补充没有的信息 if (!in_array($val['sku'], $pur_sku_arr)) { unset($data[$key]); //去除不是自己的sku continue; } $spu = $good->getSpuBySku($val['sku']); $data[$key]['spu'] = $spu; } } if (!empty($data)) { $perNum = 100; $pageArr = pageForArr($data, $perNum); $pageStr = $pageArr[1]; $list = $pageArr[0]; } } else { $pageStr = '暂无数据'; } $this->smarty->assign('pageStr', $pageStr); //分页输出 $this->smarty->assign('ser_sku', $sku); //选中SKU $this->smarty->assign('ser_timetype', $timetype); //选中时间类型 $this->smarty->assign('ser_startTime', $starttime); //选中开始时间 $this->smarty->assign('ser_endTime', $endtime); //选中结束时间 $this->smarty->assign('ser_status', $status); //选中状态 $this->smarty->assign('userid', $_SESSION['userId']); //登录用户userid $this->smarty->assign('list', $list); //循环赋值 $this->smarty->display('badGood.htm'); }