function act_updateTNameRow($tName, $set, $where) { $ret = OmAvailableModel::updateTNameRow($tName, $set, $where); if ($ret !== FALSE) { return $ret; } else { self::$errCode = OmAvailableModel::$errCode; self::$errMsg = OmAvailableModel::$errMsg; return false; } }
public function view_updateSpuArchiveOn() { $spu = $_POST['spu'] ? post_check(trim($_POST['spu'])) : ''; $pid = $_POST['pid'] ? post_check(trim($_POST['pid'])) : ''; $seach_spu = isset($_POST['seach_spu']) ? $_POST['seach_spu'] : ''; $seach_auditStatus = isset($_POST['seach_auditStatus']) ? $_POST['seach_auditStatus'] : ''; $seach_spuStatus = isset($_POST['seach_spuStatus']) ? $_POST['seach_spuStatus'] : ''; $seach_purchaseId = isset($_POST['seach_purchaseId']) ? $_POST['seach_purchaseId'] : ''; $seach_pid = isset($_POST['seach_pid']) ? $_POST['seach_pid'] : ''; $seach_isPPVRecord = isset($_POST['seach_isPPVRecord']) ? $_POST['seach_isPPVRecord'] : ''; $seach_haveSizePPV = isset($_POST['seach_haveSizePPV']) ? $_POST['seach_haveSizePPV'] : ''; $seach_isMeasureRecord = isset($_POST['seach_isMeasureRecord']) ? $_POST['seach_isMeasureRecord'] : ''; $seach_dept = isset($_POST['seach_dept']) ? $_POST['seach_dept'] : ''; $seach_page = isset($_POST['seach_page']) ? $_POST['seach_page'] : ''; $seach_startdate = isset($_POST['seach_startdate']) ? $_POST['seach_startdate'] : ''; $seach_enddate = isset($_POST['seach_enddate']) ? $_POST['seach_enddate'] : ''; //检查spu,pid是否非法 if (empty($spu)) { $status = "spu为空"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (empty($pid)) { $status = "类别为空"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } $tName = 'pc_auto_create_spu'; $select = 'sort,purchaseId,isSingSpu'; $where = "WHERE spu='{$spu}' and is_delete=0"; $autoSpuList = OmAvailableModel::getTNameList($tName, $select, $where); if (empty($autoSpuList)) { $status = "自动生成SPU中不存在 {$spu}"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } $tName = 'pc_spu_archive'; $where = "WHERE spu='{$spu}' and categoryPath='{$pid}' and is_delete=0"; $count = OmAvailableModel::getTNameCount($tName, $where); if (!$count) { $status = "产品档案中不存在 {$spu} 的信息"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } $tName = 'pc_goods_category'; $where = "WHERE path='{$pid}' and is_delete=0"; $count = OmAvailableModel::getTNameCount($tName, $where); if (!$count) { $status = "系统不存在该类别"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } //获取网页传来的数据 $dataSpu = array(); //spu档案属性 $dataSpu['spuName'] = $_POST['spuName'] ? trim($_POST['spuName']) : ''; //描述 $dataSpu['spuPurchasePrice'] = $_POST['spuPurchasePrice'] ? post_check(trim($_POST['spuPurchasePrice'])) : ''; $dataSpu['spuLowestPrice'] = $_POST['spuLowestPrice'] ? post_check(trim($_POST['spuLowestPrice'])) : ''; $dataSpu['spuCalWeight'] = $_POST['spuCalWeight'] ? post_check(trim($_POST['spuCalWeight'])) : ''; $dataSpu['referMonthSales'] = $_POST['referMonthSales'] ? post_check(trim($_POST['referMonthSales'])) : ''; $spId = $_POST['spId']; //特殊属性数组 add zqt 20140819 $dataSpu['minNum'] = $_POST['minNum'] ? post_check(trim($_POST['minNum'])) : ''; //起订量 $dataSpu['platformId'] = $_POST['platformId'] ? post_check(trim($_POST['platformId'])) : ''; //对应平台 $dataSpu['freight'] = $_POST['freight'] ? post_check(trim($_POST['freight'])) : 0; //运费 $dataSpu['secretInfo'] = $_POST['secretInfo'] ? post_check(trim($_POST['secretInfo'])) : ''; //隐私信息,目前为被PK料号信息 $dataSpu['lowestUrl'] = $_POST['lowestUrl'] ? post_check(trim($_POST['lowestUrl'])) : ''; $dataSpu['bidUrl'] = $_POST['bidUrl'] ? post_check(trim($_POST['bidUrl'])) : ''; if (empty($dataSpu['spuName'])) { $status = "描述不能为空"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (!is_numeric($dataSpu['spuPurchasePrice']) || $dataSpu['spuPurchasePrice'] <= 0) { $status = "采购价必须是正数"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (!is_numeric($dataSpu['spuLowestPrice']) || $dataSpu['spuLowestPrice'] <= 0) { $status = "市场最低价必须是正数"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (!is_numeric($dataSpu['spuCalWeight']) || $dataSpu['spuCalWeight'] <= 0) { $status = "估算重量必须是正数"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (intval($dataSpu['referMonthSales']) == 0) { $status = "参考月销量必须为大于0的正数"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (intval($dataSpu['minNum']) <= 0) { $status = "起订量必须为大于0的正数"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (intval($dataSpu['platformId']) <= 0) { $status = "对应平台选择有误"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (!is_numeric($dataSpu['freight']) || $dataSpu['freight'] < 0) { $status = "运费必须为非负数"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (empty($dataSpu['lowestUrl'])) { $status = "最低价链接不能为空"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } if (empty($dataSpu['bidUrl'])) { $status = "参考listing链接不能为空"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); exit; } $dataSpu['spuNote'] = $_POST['spuNote'] ? post_check(trim($_POST['spuNote'])) : ''; $dataSpu['spuStatus'] = $_POST['spuStatus'] ? post_check(trim($_POST['spuStatus'])) : 1; $dataSpu['spuCreatedTime'] = time(); //最后一次修改的时间 $dataLink = array(); //spuLink属性 $dataLinkTmp['spu'] = $spu; $linkUrlArr = $_POST['linkUrl']; $linkNoteArr = $_POST['linkNote']; for ($i = 0; $i < count($linkUrlArr); $i++) { $dataLinkTmp['spu'] = $spu; $dataLinkTmp['linkUrl'] = $linkUrlArr[$i]; $dataLinkTmp['linkNote'] = $linkNoteArr[$i]; $dataLink[] = $dataLinkTmp; } //add 20140526 筛选的PK SKU if ($dataSpu['spuStatus'] == 51 && empty($dataSpu['secretInfo'])) { $tmpStatus = "PK状态下,PK的SPU不能为空!"; echo '<script language="javascript"> alert("' . $tmpStatus . '"); history.back(); </script>'; exit; } if (!preg_match("/^[A-Z0-9]+\$/", $dataSpu['secretInfo']) && !empty($dataSpu['secretInfo'])) { $tmpStatus = "被PK的SPU只能是大写字母和数字字符串!"; echo '<script language="javascript"> alert("' . $tmpStatus . '"); history.back(); </script>'; exit; } $pkSkuArr = !empty($_POST['pkSku']) ? $_POST['pkSku'] : array(); if ($dataSpu['spuStatus'] == 51) { //状态为pk $tName = 'pc_spu_archive'; $select = 'auditTime'; $where = "WHERE is_delete=0 and spu='{$spu}'"; $auditTimeList = OmAvailableModel::getTNameList($tName, $select, $where); if ($auditTimeList[0]['auditTime'] > 1401465600 && count($pkSkuArr) <= 0) { //审核时间大于这个时候开始验证,否则不验证pkSku的值 $tmpStatus = "请填写完PK的SPU后点击'筛选SKU'按钮选择所PK的SKU,谢谢!"; echo '<script language="javascript"> alert("' . $tmpStatus . '"); history.back(); </script>'; exit; } } // $pathImplodeStr = getAllPathBypid($pid); $dataPro = array(); $tName = 'pc_archive_property'; $select = '*'; $where = "WHERE categoryPath IN ({$pathImplodeStr})"; $proList = OmAvailableModel::getTNameList($tName, $select, $where); if (!empty($proList)) { foreach ($proList as $value) { $tmpArr = array(); if ($value['isRadio'] == 1) { //单选 $tmpArr['spu'] = $spu; $tmpArr['propertyId'] = $value['id']; $tmpArr['propertyValueId'] = $_POST['pro' . $value['id']]; //单选时,$_POST['pro'.$value['id']]存放的是一个字符串 $dataPro[] = $tmpArr; } else { //多选 //多选时,$_POST['pro'.$value['id']]存放的是一个数组,固定某个propertyId下的多个值 $tmpPostValueArr = $_POST['pro' . $value['id']]; if (!empty($tmpPostValueArr)) { foreach ($tmpPostValueArr as $value2) { $tmpArr['spu'] = $spu; $tmpArr['propertyId'] = $value['id']; $tmpArr['propertyValueId'] = $value2; $dataPro[] = $tmpArr; } } } } } $dataInp = array(); $tName = 'pc_archive_input'; $select = '*'; $where = "WHERE categoryPath IN ({$pathImplodeStr})"; $inpList = OmAvailableModel::getTNameList($tName, $select, $where); if (!empty($inpList)) { foreach ($inpList as $value) { $tmpArr = array(); $tmpArr['spu'] = $spu; $tmpArr['inputId'] = $value['id']; $tmpArr['inputValue'] = $_POST['inp' . $value['id']]; $dataInp[] = $tmpArr; } } try { BaseModel::begin(); //pc_spu_archive中插入数据 $tName = 'pc_spu_archive'; $where = "WHERE spu='{$spu}'"; $affectRowSpu = OmAvailableModel::updateTNameRow2arr($tName, $dataSpu, $where); if ($affectRowSpu === false) { throw new Exception('add pc_spu_archive error'); } //add zqt 20140711 添加特殊属性 if (!empty($spId) && is_array($spId)) { $tName = 'pc_special_property_spu'; $where = "WHERE spu='{$spu}'"; OmAvailableModel::deleteTNameRow($tName, $where); foreach ($spId as $propertyIdValue) { $propertyIdValue = intval($propertyIdValue); $dataTmpArr = array(); $dataTmpArr['propertyId'] = $propertyIdValue; $dataTmpArr['spu'] = $spu; OmAvailableModel::addTNameRow2arr($tName, $dataTmpArr); } } //add 20140526 更新PK细分SKU $tName = 'pc_spu_archive_pk_sku'; $where = "WHERE spu='{$spu}'"; OmAvailableModel::deleteTNameRow($tName, $where); //先删掉之前关联的记录 foreach ($pkSkuArr as $value) { $tName = 'pc_spu_archive_pk_sku'; $dataPkSkuArr['spu'] = $spu; $dataPkSkuArr['sku'] = $value; OmAvailableModel::addTNameRow2arr($tName, $dataPkSkuArr); } //pc_archive_spu_link中插入数据 $tName = 'pc_archive_spu_link'; if (!empty($dataLink)) { $affectRowDelLnk = OmAvailableModel::deleteTNameRow($tName, $where); if ($affectRowDelLnk === false) { throw new Exception('delete pc_archive_spu_link error'); } foreach ($dataLink as $value) { if (!empty($value['linkUrl'])) { $insertIdLink = OmAvailableModel::addTNameRow2arr($tName, $value); if ($insertIdLink === false) { throw new Exception('add pc_archive_spu_link error'); } } } } //pc_archive_spu_property_value_relation中插入数据 $tName = 'pc_archive_spu_property_value_relation'; if (!empty($dataPro)) { $affectRowDelPro = OmAvailableModel::deleteTNameRow($tName, $where); if ($affectRowDelPro === false) { throw new Exception('delete pc_archive_spu_property_value_relation error'); } foreach ($dataPro as $value) { if (!empty($value['propertyValueId'])) { $insertIdPro = OmAvailableModel::addTNameRow2arr($tName, $value); if ($insertIdPro === false) { throw new Exception('add pc_archive_spu_property_value_relation error'); } } } } //pc_archive_spu_input_value_relation中插入数据 $tName = 'pc_archive_spu_input_value_relation'; if (!empty($dataInp)) { $affectRowDelInp = OmAvailableModel::deleteTNameRow($tName, $where); if ($affectRowDelInp === false) { throw new Exception('delete pc_archive_spu_input_value_relation error'); } foreach ($dataInp as $value) { if (trim($value['inputValue']) != '') { $insertIdPro = OmAvailableModel::addTNameRow2arr($tName, $value); if ($insertIdPro === false) { throw new Exception('add pc_archive_spu_property_value_relation error'); } } } } //添加尺寸测量项 $spuPPVrelationList = isExistForSpuPPV($spu, '尺码'); //先获取该spu下是否已经存在尺寸的属性值 if (!empty($spuPPVrelationList)) { //如果该spu下存在尺码属性值 foreach ($spuPPVrelationList as $valueRelation) { //循环遍历,将尺码下的属性值全部遍历出来,如S,M,X,XL等 $tName = 'pc_archive_input'; $select = '*'; $where = "WHERE textStatus=1 AND categoryPath IN ({$pathImplodeStr})"; $inputList = OmAvailableModel::getTNameList($tName, $select, $where); //根据$pid,获取该类别下的尺寸测量属性值,如胸围,腰围,衣长, foreach ($inputList as $valueInput) { $inputName = $valueInput['inputName']; //根据inputId获取对应名称 $PPVname = getPPVForPPVId($valueRelation['propertyValueId']); //根据ppvId获取对应的名称 $postNameValue = $_POST[$inputName . $PPVname] ? post_check(trim($_POST[$inputName . $PPVname])) : ''; //$inputName.$PPVname为前台传过来的对应值 //echo $postNameValue.'<br/>'; if (!empty($postNameValue) && !empty($inputName) && !empty($PPVname)) { //如果前端传过来的值不为空的话 $tName = 'pc_archive_spu_input_size_measure'; $where = "WHERE spu='{$spu}' and sizeName='{$PPVname}' and inputName='{$inputName}'"; $spuMeasureCount = OmAvailableModel::getTNameCount($tName, $where); if ($spuMeasureCount) { //记录存在的话,则修改 $set = "SET valued='{$postNameValue}'"; OmAvailableModel::updateTNameRow($tName, $set, $where); } else { //不存在则插入 $dataMeasure = array(); $dataMeasure['spu'] = $spu; $dataMeasure['sizeName'] = $PPVname; $dataMeasure['inputName'] = $inputName; $dataMeasure['valued'] = $postNameValue; $dataMeasure['addUserId'] = $_SESSION['userId']; $dataMeasure['addTime'] = time(); OmAvailableModel::addTNameRow2arr($tName, $dataMeasure); } } } } } BaseModel::commit(); BaseModel::autoCommit(); $status = "{$spu} 产品档案修改成功"; header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); } catch (Exception $e) { BaseModel::rollback(); BaseModel::autoCommit(); $status = $e->getMessage(); header("Location:index.php?mod=autoCreateSpu&act=getSpuArchiveList&status={$status}&spu={$seach_spu}&spuStatus={$seach_spuStatus}&auditStatus={$seach_auditStatus}&purchaseId={$seach_purchaseId}&pid={$seach_pid}&isPPVRecord={$seach_isPPVRecord}&haveSizePPV={$seach_haveSizePPV}&isMeasureRecord={$seach_isMeasureRecord}&dept={$seach_dept}&page={$seach_page}&startdate={$seach_startdate}&enddate={$seach_enddate}"); } }
public function act_packingTracknumber() { $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : ""; $tracknumber = isset($_POST['tracknumber']) ? $_POST['tracknumber'] : ""; $userId = $_SESSION['userId']; //先核对订单 //兼容 EUB或者 包裹 扫描的是 trackno 而非ebayid $p_real_ebayid = '#^\\d+$#'; $p_trackno_eub = '#^(LK|RA|RB|RC|RR|RF|LN)\\d+(CN|HK|DE200)$#'; $is_eub_package_type = false; if (preg_match($p_real_ebayid, $orderid)) { } else { if (preg_match($p_trackno_eub, $orderid)) { $is_eub_package_type = true; } else { self::$errCode = "001"; self::$errMsg = "订单号[" . $orderid . "]格式有误"; return false; } } if ($is_eub_package_type === true) { $record = ShippingOrderModel::getShippingOrderInfo("b.*", "where a.tracknumber='{$orderid}' and a.is_delete=0"); } else { $record = ShippingOrderModel::getShippingOrder("*", "where id='{$orderid}'"); } //验证发货单号 以及所属状态 if (!$record) { self::$errCode = 404; self::$errMsg = "发货单号不存在!"; return false; } if ($record[0]['orderStatus'] != 404) { self::$errCode = 405; self::$errMsg = "此发货单不在待包装!"; if ($record[0]['orderStatus'] == 900) { self::$errMsg = "此发货单已废弃!"; } return false; } //挂号的单需要再输入挂号条码 $carrier = CommonModel::getShipingNameById($record[0]['transportId']); $partion = CommonModel::getChannelNameByIds($record[0]['transportId'], $record[0]['countryName']); $total_num = 0; $skuinfos = get_realskunum($record[0]['id']); foreach ($skuinfos as $or_sku => $or_nums) { $total_num += $or_nums; } if (carrier == '中国邮政挂号' && !preg_match("/^(RA|RB|RC|RR)\\d+(CN)\$/", $tracknumber)) { self::$errCode = 111; self::$errMsg = "录入失败,中国邮政挂号跟踪码不符合规范"; return false; } if ($carrier == '香港小包挂号' && !preg_match("/^(RA|RB|RC|RR)\\d+(HK)\$/", $tracknumber)) { self::$errCode = 111; self::$errMsg = "录入失败,香港小包挂号跟踪码不符合规范"; return false; } $p_str = "挂号条码:" . "<font color='#FF0000'>" . $tracknumber . "</font> <br>"; TransactionBaseModel::begin(); //更新订单状态 $msg = OmAvailableModel::updateTNameRow("wh_shipping_order", "set orderStatus=405", "where id={$record[0]['id']}"); if (!$msg) { self::$errCode = 409; self::$errMsg = "更新发货单状态记录失败!"; $arr['partion'] = $partion; $arr['carrier'] = $carrier; TransactionBaseModel::rollback(); return json_encode($arr); exit; } //更新操作记录 $msg = packingScanOrderModel::updateOrderRecord($record[0]['id'], $userId); if (!$msg) { self::$errCode = 406; self::$errMsg = "更新发货单操作记录失败!"; TransactionBaseModel::rollback(); return false; } //插入包装记录 $msg = packingScanOrderModel::insertPackingRecord($record[0]['id'], $userId); if (!$msg) { self::$errCode = 407; self::$errMsg = "插入包装记录失败!"; TransactionBaseModel::rollback(); return false; } $msg = packingScanOrderModel::deleteTrackRecord($record[0]['id']); if (!$msg) { self::$errCode = 409; self::$errMsg = "删除跟踪记录失败!"; TransactionBaseModel::rollback(); return false; } //录入挂号条码 $msg = packingScanOrderModel::insertTrackRecord($tracknumber, $record[0]['id']); if (!$msg) { self::$errCode = 408; self::$errMsg = "插入包装记录失败!"; TransactionBaseModel::rollback(); return false; } WhPushModel::pushOrderStatus($record[0]['id'], 'STATESHIPPED_BEWEIGHED', $userId, time(), '', $tracknumber); //状态推送 $arr['partion'] = "<font color='#FF0000'>该订单属于" . $partion . ";含SKU总数:" . $total_num . "个</font><br>"; $arr['carrier'] = $carrier; $arr['res'] = $arr['partion'] . "包装人员:" . "<font color='green'>" . $_SESSION['userCnName'] . "</font><br>" . "运输方式:" . "<font color='#FF0000'>" . $carrier . "</font> <br>" . $p_str . "扫描结果:<font color='#33CC33'>包装扫描成功!</font>"; TransactionBaseModel::commit(); return $arr; }
/** *功能:提供给仓库系统的接口,重量拦截重新得到重量 * */ public function act_setSkuWeightInWh() { $sku = isset($_GET['sku']) ? $_GET['sku'] : ""; $skuweight = isset($_GET['skuweight']) ? $_GET['skuweight'] / 1000 : ""; //传递过来的重量为g $userId = isset($_GET['userId']) ? $_GET['userId'] : 0; if (intval($userId) <= 0) { self::$errCode = 111; self::$errMsg = "登陆超时,请重新登陆!"; return false; } if (empty($sku) || empty($skuweight)) { self::$errCode = 333; self::$errMsg = "料号或重量不能为空!"; return false; } $skuList = getSkuBygoodsCode($sku); //根据条码获取真实sku if (empty($skuList)) { self::$errCode = 404; self::$errMsg = '料号不存在'; return false; } $oldWeight = !empty($skuList[0]['goodsWeight']) ? $skuList[0]['goodsWeight'] : 0; //先找出该sku的重量 if ($oldWeight != $skuweight) { //如果新旧重量不相等时,则更新 try { BaseModel::begin(); $tName = 'pc_goods'; $set = "SET goodsWeight='{$skuweight}'"; $where = "WHERE sku='{$skuList[0]['sku']}'"; OmAvailableModel::updateTNameRow($tName, $set, $where); //$info = UserCacheModel::getOpenSysApi('pc.updateTNameRow',array(array('tName'=>"pc_goods",'set'=>"goodsWeight='{$skuweight}'",'where'=>"WHERE sku='{$sku}' and is_delete = 0"))); //添加重量备份记录 //$tName = 'pc_goods_weight_backups'; // $backupsArr = array (); // $backupsArr['sku'] = $skuList[0]['sku']; // $backupsArr['goodsWeight'] = $skuweight; // $backupsArr['addUserId'] = $userId; // $backupsArr['addTime'] = time(); // OmAvailableModel :: addTNameRow2arr($tName, $backupsArr); addWeightBackupsModify($skuList[0]['sku'], $skuweight, $userId); // //$url = "add2ebay_goods_weight.php?goods_sn=".$skuList[0]['sku']."&goods_weight=".$skuweight; // OmAvailableModel::newData2ErpInterf($url); $paraArr['goods_sn'] = $skuList[0]['sku']; $paraArr['goods_weight'] = $skuweight; $res = OmAvailableModel::newData2ErpInterfOpen('pc.erp.addGoodsSnWeight', $paraArr, 'gw88'); //print_r($res); // exit; BaseModel::commit(); BaseModel::autoCommit(); $string = empty($oldWeight) ? "(Kg) 录入成功!" : "(Kg) 更新成功,原来重量为 {$oldWeight}(Kg)"; self::$errCode = 200; self::$errMsg = $skuList[0]['sku'] . " 重量 " . $skuweight . $string; return true; } catch (Exception $e) { BaseModel::rollback(); BaseModel::autoCommit(); self::$errCode = 404; self::$errMsg = $skuList[0]['sku'] . " 重量 " . $skuweight . "(Kg) 录入失败! " . $e->getMessage(); return false; } } else { self::$errCode = 200; self::$errMsg = $skuList[0]['sku'] . " 重量 无修改,为 {$skuweight}(Kg)"; return true; } }
public function act_whReturnSkuShelf() { //print_r($_POST); $sku = trim($_POST['sku']); $sku = get_goodsSn($sku); $nums = $_POST['nums']; $select_now_position = $_POST['select_now_position']; $select_now_store = $_POST['select_now_store']; $select_hope_position = $_POST['select_hope_position']; $select_hope_store = $_POST['select_hope_store']; if (empty($sku)) { self::$errCode = 401; self::$errMsg = "sku不能为空"; return false; } if (empty($select_now_position) && empty($select_now_store) && empty($select_hope_position) && empty($select_hope_store)) { self::$errCode = 401; self::$errMsg = "上架位置不能为空"; return false; } $where = "where sku='{$sku}' and status=0"; $tallying_list = PostReturnModel::getReturnList("*", $where); if (empty($tallying_list)) { self::$errCode = 402; self::$errMsg = "无该料号退回信息"; return false; } else { $tallying_num = 0; foreach ($tallying_list as $tallying) { $tallying_num += $tallying['ichibanNums'] - $tallying['shelvesNums']; } if ($nums > $tallying_num) { self::$errCode = 402; self::$errMsg = "上架数不能大于qc良品数[{$tallying_num}]"; return false; } } if ($nums < 1) { self::$errCode = 403; self::$errMsg = "入库数量不能小于1"; return false; } $where = " where sku = '{$sku}'"; $skuinfo = whShelfModel::selectSku($where); if (empty($skuinfo)) { self::$errCode = 404; self::$errMsg = "无该料号信息"; return false; } else { $skuId = $skuinfo['id']; $purchaseId = $skuinfo['purchaseId']; } $userId = $_SESSION['userId']; $in_positionId = 0; TransactionBaseModel::begin(); /***无料号对应仓位的关系时更新关系表***/ if ($select_hope_store != 0 || $select_hope_position != 0) { $type = 1; $positionId = $select_hope_position; if ($select_hope_store != 0) { $type = 2; $positionId = $select_hope_store; } $in_positionId = $positionId; $tname = "wh_product_position_relation"; $set = "set pId='{$skuId}',positionId='{$positionId}',nums='{$nums}',type='{$type}'"; $insert_relation = OmAvailableModel::insertRow($tname, $set); if (!$insert_relation) { self::$errCode = 408; self::$errMsg = "插入关系表失败!"; TransactionBaseModel::rollback(); return false; } //更新仓位使用状态 $update_position = OmAvailableModel::updateTNameRow("wh_position_distribution", "set is_enable=1", "where id={$positionId}"); if ($update_position === false) { self::$errCode = 409; self::$errMsg = "更新仓位使用状态失败!"; TransactionBaseModel::rollback(); return false; } } //更新指定仓位存货数量 if ($select_now_store != 0) { $positioninfo = whShelfModel::selectRelation("where id={$select_now_store}"); $in_positionId = $positioninfo[0]['positionId']; $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$select_now_store}'"); if (!$update_position) { self::$errCode = 410; self::$errMsg = "更新仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } if ($select_now_store == 0 && $select_hope_position == 0 && $select_hope_store == 0) { $positioninfo = whShelfModel::selectRelation("where id={$select_now_position}"); $in_positionId = $positioninfo[0]['positionId']; $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$select_now_position}'"); if (!$update_position) { self::$errCode = 411; self::$errMsg = "更新仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } /**** 更新总库存 *****/ $where = "where sku='{$sku}'"; $info = whShelfModel::updateStoreNumOnly($nums, $where); if (!$info) { self::$errCode = 412; self::$errMsg = "更新总库存失败!"; TransactionBaseModel::rollback(); return false; } /**** 插入出入库记录 *****/ $paraArr = array('sku' => $sku, 'amount' => $nums, 'positionId' => $in_positionId, 'purchaseId' => $purchaseId, 'ioType' => 2, 'ioTypeId' => 14, 'userId' => $userId, 'reason' => '退货料号入库'); $record = CommonModel::addIoRecores($paraArr); //出库记录 if (!$record) { self::$errCode = 413; self::$errMsg = "插入出入库记录失败!"; TransactionBaseModel::rollback(); return false; } //更新邮局退回记录状态 $where = "where sku='{$sku}' and status=0 and ichibanNums>0"; $list = PostReturnModel::getReturnList("*", $where); $i = 0; while ($list[$i] && $nums) { $need_nums = $list[$i]['ichibanNums'] - $list[$i]['shelvesNums']; if ($nums >= $need_nums) { //更改状态 $msg = PostReturnModel::updateReturnStatus($list[$i]['id'], $need_nums); if (!$msg) { self::$errCode = 413; self::$errMsg = "更新邮局退回记录状态失败!"; TransactionBaseModel::rollback(); return false; } $nums = $nums - $need_nums; } else { $msg = PostReturnModel::updateReturnShelfNum($list[$i]['id'], $nums); if (!$msg) { self::$errCode = 414; self::$errMsg = "更新邮局退回记录已上架数量失败!"; TransactionBaseModel::rollback(); return false; } $nums = 0; } $i++; } TransactionBaseModel::commit(); self::$errMsg = "料号[{$sku}]入库成功!"; return true; }
function act_operatUnusualOrder() { $purid = isset($_GET['purid']) ? $_GET['purid'] : ''; $oid = isset($_GET['oid']) ? base64_decode($_GET['oid']) : ''; $category = isset($_GET['category']) ? $_GET['category'] : ''; if (empty($purid) || empty($oid) || empty($category)) { //参数不完整 self::$errCode = 101; self::$errMsg = '参数信息不完整'; return false; } $nowtime = time(); if ($category == 'comfirmorder') { $rtn = OmAvailableModel::updateTNameRow("wh_abnormal_purchase_orders", "set isConfirm=1,confirmUserId='{$purid}'", "where id in {$oid}"); } else { if ($category == 'patchorder') { $recordnumber = isset($_GET['recordnumber']) ? $_GET['recordnumber'] : ''; $rtn = OmAvailableModel::updateTNameRow("wh_abnormal_purchase_orders", "set abStatus=1,ioOrdersn='{$recordnumber}'", "where isConfirm=1 and id in {$oid}"); } else { if ($category == 'setzero') { $rtn = OmAvailableModel::updateTNameRow("wh_abnormal_purchase_orders", "set abStatus=3,nums=0", "where isConfirm=1 and id in {$oid}"); } else { if ($category == 'secondstockin') { $rtn = OmAvailableModel::updateTNameRow("wh_abnormal_purchase_orders", "set abStatus=3,nums=0", "where isConfirm=1 and id in {$oid}"); } else { if ($category == 'backorder') { $rtn = OmAvailableModel::updateTNameRow("wh_abnormal_purchase_orders", "set abStatus=2,cancelTime='{$nowtime}',cancelUserId='{$purid}'", "where isConfirm=1 and id in {$oid}"); } } } } } if ($rtn === false) { self::$errCode = 102; self::$errMsg = '操作失败'; return false; } else { return true; } }
public function act_completion() { $order_id = $_POST['ebay_id']; //先核对订单 $p_real_ebayid = '#^\\d+$#'; if (!preg_match($p_real_ebayid, $order_id)) { self::$errCode = "100"; self::$errMsg = "订单号[" . $order_id . "]格式有误"; return false; } $complete = ShippingOrderModel::update(array('orderStatus' => PKS_UNUSUAL_SHIPPING_INVOICE), "and id='{$order_id}'"); // $complete = 111; if ($complete) { $time = time(); OmAvailableModel::updateTNameRow("wh_order_review_records", "set scanUserId='{$_SESSION['userId']}',scanTime={$time},isScan = 1", "where shipOrderId={$order_id}"); // WhPushModel::pushOrderStatus($ordercheck[0]['id'],PKS_UNUSUAL_SHIPPING_INVOICE,$_SESSION['userId'],$time); //状态推送,需要改为异常发货单(订单系统提供状态常量) self::$errCode = 200; self::$errMsg = '订单[' . $order_id . ']复核(拍照)成功,请扫描复核下一订单'; $res['shipOrderId'] = $order_id; return $res; } else { self::$errCode = "006"; self::$errMsg = '订单复核出现异常,请重新复核'; return false; } }
function updateNewPostion($sku, $location) { global $dbConn; $goodsinfos = OmAvailableModel::getTNameList("pc_goods", "sku,id", "where sku='{$sku}'"); $pId = $goodsinfos[0]['id']; //产品id if ($location) { $sql1 = "select * from `wh_position_distribution` where pName = '{$location}'"; $query = $dbConn->query($sql1); $wh_position_distribution = $dbConn->fetch_array($query); if ($wh_position_distribution) { $positionId = $wh_position_distribution['id']; //$postionId = OmAvailableModel::insertRow2("wh_position_distribution","set pName='$location',x_alixs=0,y_alixs=0,z_alixs=0,floor=0,is_enable=0,type=1,storeId=2"); if ($positionId) { $positioninfos = OmAvailableModel::getTNameList("wh_product_position_relation", "id", "where pId='{$pId}' and storeId = '{$wh_position_distribution['storeId']}'"); if (!empty($positioninfos)) { if ($data = OmAvailableModel::updateTNameRow("wh_product_position_relation", "set positionId='{$positionId}', storeId={$wh_position_distribution['storeId']}", " where pId='{$pId}' and storeId = '{$wh_position_distribution['storeId']}'")) { //echo "update <".$sku."> ===(".$positionId.") success\n"; return true; } else { return false; } } else { //$infos = OmAvailableModel::getTNameList("wh_sku_location","sku,actualStock","where sku='{$sku}'"); // $num = $info['actualStock']; $data = OmAvailableModel::insertRow("wh_product_position_relation", "set pId='{$pId}',positionId='{$positionId}', storeId={$wh_position_distribution['storeId']}"); } } else { return false; } } else { return false; } } }
public function act_whShelf() { //print_r($_POST); $userCnName = $_SESSION['userCnName']; $sku = trim($_POST['sku']); $sku = get_goodsSn($sku); $nums = $_POST['nums']; $select_now_position = $_POST['select_now_position']; $select_now_store = $_POST['select_now_store']; $select_hope_position = $_POST['select_hope_position']; $select_hope_store = $_POST['select_hope_store']; if (empty($sku)) { self::$errCode = 401; self::$errMsg = "sku不能为空"; return false; } if (empty($select_now_position) && empty($select_now_store) && empty($select_hope_position) && empty($select_hope_store)) { self::$errCode = 401; self::$errMsg = "上架位置不能为空"; return false; } /* $where = "where sku='{$sku}' and tallyStatus=0"; $tallying_list = packageCheckModel::selectList($where); if(empty($tallying_list)){ self::$errCode = 402; self::$errMsg = "无该料号点货信息"; return false; }else{ $tallying_num = 0; foreach($tallying_list as $tallying){ $tallying_num += $tallying['ichibanNums']-$tallying['shelvesNums']; } if($nums>$tallying_num){ self::$errCode = 402; self::$errMsg = "上架数不能大于点货良品数[{$tallying_num}]"; return false; } } */ if ($nums < 1) { self::$errCode = 403; self::$errMsg = "上架数量不能小于1"; return false; } $where = " where sku = '{$sku}'"; $skuinfo = whShelfModel::selectSku($where); if (empty($skuinfo)) { self::$errCode = 404; self::$errMsg = "无该料号信息"; return false; } else { $skuId = $skuinfo['id']; $purchaseId = $skuinfo['purchaseId']; } /* $purInfo = CommonModel::endPurchaseOrder($sku,$nums); //api获取采购订单处理情况 if($purInfo!=0){ self::$errCode = 405; self::$errMsg = "完结采购订单出错,上架失败"; return false; } //更新旧erp库存 $update_onhand = CommonModel::updateOnhand($sku,$nums); if($update_onhand==0){ self::$errCode = 415; self::$errMsg = "更新erp库存失败"; return false; }*/ $return_num = $nums; $in_positionId = 0; $userId = $_SESSION['userId']; TransactionBaseModel::begin(); /****插入采购未订单记录****/ /* if($return_num>0){ $where = " where sku = '{$sku}' and tallyStatus=0"; $list = whShelfModel::selectList($where); $purchaseId = $list[0]['purchaseId']; $totalNums = 0; foreach($list as $key=>$value){ $totalNums += $value['num']; } if ($return_num==$nums){ $reach_note = "sku[{$sku}]到货{$nums}个,未找到该料号的订单,请物料点货确认和采购补单!"; }else{ $reach_note = "sku[{$sku}]到货{$nums}个,入库完毕后还多余{$return_num}个,请物料点货确认和采购补单!"; } $msg = whShelfModel::insertNoOrder($sku,$return_num,$totalNums,$purchaseId,$userId,$reach_note); if(!$msg){ self::$errCode = whShelfModel::$errCode; self::$errMsg = whShelfModel::$errMsg; return false; } } */ /***无料号对应仓位的关系时更新关系表***/ if ($select_hope_store != 0 || $select_hope_position != 0) { $type = 1; $positionId = $select_hope_position; if ($select_hope_store != 0) { $type = 2; $positionId = $select_hope_store; } $in_positionId = $positionId; $tname = "wh_product_position_relation"; $set = "set pId='{$skuId}',positionId='{$positionId}',nums='{$nums}',type='{$type}',storeId=2"; $insert_relation = OmAvailableModel::insertRow($tname, $set); if (!$insert_relation) { self::$errCode = 408; self::$errMsg = "插入关系表失败!"; TransactionBaseModel::rollback(); return false; } //更新仓位使用状态 $update_position = OmAvailableModel::updateTNameRow("wh_position_distribution", "set is_enable=1", "where id={$positionId}"); if ($update_position === false) { self::$errCode = 409; self::$errMsg = "更新仓位使用状态失败!"; TransactionBaseModel::rollback(); return false; } } //更新指定仓位存货数量 if ($select_now_store != 0) { $positioninfo = whShelfModel::selectRelation("where id={$select_now_store}"); $in_positionId = $positioninfo[0]['positionId']; $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$select_now_store}'"); if (!$update_position) { self::$errCode = 410; self::$errMsg = "更新仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } if ($select_now_store == 0 && $select_hope_position == 0 && $select_hope_store == 0) { $positioninfo = whShelfModel::selectRelation("where id={$select_now_position}"); $in_positionId = $positioninfo[0]['positionId']; $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$select_now_position}'"); if (!$update_position) { self::$errCode = 411; self::$errMsg = "更新仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } /**** 更新总库存 *****/ $actualStock = whShelfModel::selectSkuNums($sku, 2); if (!empty($actualStock)) { $where = "where sku='{$sku}' and storeId=2"; $info = whShelfModel::updateStoreNum($nums, $where); if (!$info) { self::$errCode = 412; self::$errMsg = "更新总库存失败!"; TransactionBaseModel::rollback(); return false; } } else { $info = packageCheckModel::insertStore($sku, $nums, 2); if (!$info) { self::$errCode = 412; self::$errMsg = "更新总库存失败!"; TransactionBaseModel::rollback(); return false; } } /**** 插入出入库记录 *****/ $paraArr = array('sku' => $sku, 'amount' => $nums, 'positionId' => $in_positionId, 'purchaseId' => $purchaseId, 'ioType' => 2, 'ioTypeId' => 13, 'userId' => $userId, 'reason' => '上架入库', 'storeId' => 2); $record = CommonModel::addIoRecores($paraArr); //出库记录 if (!$record) { self::$errCode = 413; self::$errMsg = "插入出入库记录失败!"; TransactionBaseModel::rollback(); return false; } /* //更新点货记录状态 $where = "where sku='{$sku}' and tallyStatus=0 and ichibanNums>0"; $list = packageCheckModel::selectList($where); $i = 0; while($list[$i]&&$nums){ $need_nums = $list[$i]['ichibanNums']-$list[$i]['shelvesNums']; if($nums >= $need_nums){ //更改状态 $msg = whShelfModel::updateTallyStatus($list[$i]['id'],$need_nums); if(!$msg){ self::$errCode = 413; self::$errMsg = "更新点货记录状态失败!"; TransactionBaseModel :: rollback(); return false; } $nums = $nums-$need_nums; }else{ $msg = whShelfModel::updateShelfNum($list[$i]['id'],$nums); if(!$msg){ self::$errCode = 414; self::$errMsg = "更新点货记录已上架数量失败!"; TransactionBaseModel :: rollback(); return false; } $nums = 0; } $i++; } */ /* $purInfo = CommonModel::endPurchaseOrder($sku,$return_num); //api获取采购订单处理情况 if($purInfo!=0){ self::$errCode = 405; self::$errMsg = "完结采购订单出错,上架失败"; TransactionBaseModel :: rollback(); return false; } //更新旧erp库存 $position_info = PositionModel::getPositionList("pName","where id={$in_positionId}"); $update_onhand = CommonModel::updateOnhand($sku,$return_num,$userCnName,$position_info[0]['pName']); if($update_onhand==0){ self::$errCode = 415; self::$errMsg = "更新旧erp库存失败"; TransactionBaseModel :: rollback(); return false; } */ TransactionBaseModel::commit(); self::$errMsg = "料号[{$sku}]上架成功!"; return true; }
function act_deleteSkuConversion() { $id = intval($_GET['id']); if ($id <= 0) { $status = "无效记录"; echo '<script language="javascript"> alert("' . $status . '"); window.history.back(); </script>'; exit; } $tName = 'pc_sku_conversion'; $set = "SET is_delete=1"; $where = "WHERE auditStatus=1 AND id={$id}"; OmAvailableModel::updateTNameRow($tName, $set, $where); $status = "删除成功"; echo '<script language="javascript"> alert("' . $status . '"); window.history.back(); </script>'; exit; }
function act_invokeListOrders(MarketplaceWebServiceOrders_Interface $service, $request, $account, $site, $accountId, $flip_transportList, $message) { // /global $account, $site, $accountId, $flip_transportList , $message; try { $response = $service->getOrder($request); //echo ("Service Response\n"); //echo ("=============================================================================\n"); if ($response->isSetGetOrderResult()) { //echo ("ListOrdersResult\n"); $listOrdersResult = $response->getGetOrderResult(); /*if ($listOrdersResult->isSetNextToken()) { //echo (" NextToken----"); //echo ($listOrdersResult->getNextToken() . "\n"); } if ($listOrdersResult->isSetCreatedBefore()) { //echo ("CreatedBefore----"); //echo ($listOrdersResult->getCreatedBefore() . "\n"); } if ($listOrdersResult->isSetLastUpdatedBefore()) { //echo ("LastUpdatedBefore----"); //echo ($listOrdersResult->getLastUpdatedBefore() . "\n"); }*/ if ($listOrdersResult->isSetOrders()) { $orders = $listOrdersResult->getOrders(); $orderList = $orders->getOrder(); $orderIndex = 1; $now = time(); //BaseModel :: begin(); //开始事务 foreach ($orderList as $order) { //echo ("***********Orders $orderIndex************\n\n"); $orderIndex++; $orderData = array(); //om_unshipped_order $orderUserInfoData = array(); //om_unshipped_order_userInfo $orderExtenData = array(); //om_unshipped_order_extension $street2 = ''; //街道2 $street3 = ''; //街道3 if ($order->isSetAmazonOrderId() && $order->isSetOrderStatus() && $order->getOrderStatus() == 'Unshipped') { //$orderData['ebay_status'] = 1; //同步进来的订单的状态 $orderData['recordNumber'] = $order->getAmazonOrderId(); //平台上的订单id //echo "AmazonOrderId ==== {$orderData['recordNumber']}\n"; } else { //echo 'getOrderStatus======' . $order->getOrderStatus() . "\n"; if ($order->getOrderStatus() == 'Shipped') { //表示已经发货了的订单 $shippedRecordNum = $order->getAmazonOrderId(); $tName = 'om_shipped_order'; $where = "WHERE recordNumber='{$shippedRecordNum}' and accountId='{$accountId}' and ShippedTime=''"; $set = "SET ShippedTime='{$now}'"; //标记发货时间 $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where); if ($affectRow) { $message .= "<font color='green'>update {$shippedRecordNum} ShippedTime success" . "</font><br>"; } else { $message .= "<font color='red'>update {$shippedRecordNum} ShippedTime fail may be has shippedTime or had no this recordNumber" . "</font><br>"; } } continue; } if ($order->isSetPurchaseDate()) { //亚马逊平台上的下单时间 $orderData['ordersTime'] = strtotime($order->getPurchaseDate()); //echo ("addTime ==== {$order->getPurchaseDate()}\n"); } if ($order->isSetLastUpdateDate()) { //支付时间 $orderData['paymentTime'] = strtotime($order->getLastUpdateDate()); //echo ("paidTime ==== {$order->getLastUpdateDate()}\n"); } $orderstatus = ''; //订单状态 //if ($order->isSetOrderStatus()) { // if($order->getOrderStatus() == 'Unshipped'){ // $orderstatus = 1; // } // } if ($order->isSetFulfillmentChannel()) { $orderExtenData['FulfillmentChannel'] = $order->getFulfillmentChannel(); //echo ("FulfillmentChannel ==== "); //订单配送方式 //echo ($orderExtenData['FulfillmentChannel'] . "\n"); } if ($order->isSetSalesChannel()) { $orderExtenData['SalesChannel'] = $order->getSalesChannel(); //echo ("SalesChannel ==== "); //echo ($orderExtenData['SalesChannel'] . "\n"); } if ($order->isSetOrderChannel()) { $orderExtenData['OrderChannel'] = $order->getOrderChannel(); //echo ("OrderChannel ===="); //echo ($orderExtenData['OrderChannel'] . "\n"); } if ($order->isSetShipServiceLevel()) { $orderExtenData['ShipServiceLevel'] = $order->getShipServiceLevel(); //echo ("ShipServiceLevel ==== "); //echo ($orderExtenData['ShipServiceLevel'] . "\n"); } if ($order->isSetShippingAddress()) { //判断是否设置了地址 $shippingAddress = $order->getShippingAddress(); if ($shippingAddress->isSetName()) { //获取收件人姓名 $orderUserInfoData['username'] = htmlentities($shippingAddress->getName(), ENT_QUOTES); //echo ("username ==== "); //echo ($orderUserInfoData['username'] . "\n"); } if ($shippingAddress->isSetAddressLine1()) { //街道1 $orderUserInfoData['street'] = htmlentities($shippingAddress->getAddressLine1(), ENT_QUOTES); //echo ("street ==== "); //echo ($orderUserInfoData['street'] . "\n"); } if ($shippingAddress->isSetAddressLine2()) { //街道2 $street2 = htmlentities($shippingAddress->getAddressLine2(), ENT_QUOTES); } if ($shippingAddress->isSetAddressLine3()) { //街道3 $street3 = htmlentities($shippingAddress->getAddressLine3(), ENT_QUOTES); } if ($shippingAddress->isSetCity()) { //城市 $orderUserInfoData['city'] = htmlentities($shippingAddress->getCity(), ENT_QUOTES); //echo ("city ==== "); //echo ($orderUserInfoData['city'] . "\n"); } if ($shippingAddress->isSetCounty()) { //郡,县 $orderUserInfoData['address2'] = htmlentities($shippingAddress->getCounty() . ' ' . $street2, ENT_QUOTES); $orderUserInfoData['address3'] = htmlentities($shippingAddress->getCounty() . ' ' . $street3, ENT_QUOTES); //echo ("address2 ==== "); //echo ($orderUserInfoData['address2'] . "\n"); //echo ("address3 ==== "); //echo ($orderUserInfoData['address3'] . "\n"); } if ($shippingAddress->isSetDistrict()) { //地方,区 //echo ("District ==== " . $shippingAddress->getDistrict() . "\n"); } if ($shippingAddress->isSetStateOrRegion()) { //州 $orderUserInfoData['state'] = htmlentities($shippingAddress->getStateOrRegion(), ENT_QUOTES); //echo ("state ==== "); //echo ($orderUserInfoData['state'] . "\n"); } if ($shippingAddress->isSetPostalCode()) { //邮编 $orderUserInfoData['zipCode'] = htmlentities($shippingAddress->getPostalCode(), ENT_QUOTES); //echo ("zipCode ==== "); //echo ($orderUserInfoData['zipCode'] . "\n"); } if ($shippingAddress->isSetCountryCode()) { //国家简称 /*$ebay_countrynames = array('US'=>'United States', "UK"=>"United Kingdom"); $orderData['ebay_couny'] = $shippingAddress->getCountryCode() ; $orderData['ebay_site'] = $shippingAddress->getCountryCode() ; $orderData['ebay_countryname'] = $ebay_countrynames[$shippingAddress->getCountryCode()];*/ //$sql = "SELECT regions_en FROM ebay_region WHERE regions_jc = '".$shippingAddress->getCountryCode()."'"; // $sql = $dbcon->execute($sql); // $amazon_countryname = $dbcon->fetch_one($sql); $orderUserInfoData['countrySn'] = $shippingAddress->getCountryCode(); //这里要调用运输方式管理系统的数据,获取国家简称对应的国家名称 $countryNameInfo = CommonModel::getCountrieInfoBySn($orderUserInfoData['countrySn']); //根据国家简称获取该国家的信息 //$orderData['ebay_site'] = $shippingAddress->getCountryCode() ; $orderUserInfoData['countryName'] = trim($countryNameInfo['regions_en']); //获得国家名称 //echo ("getCountryCode==== " . $orderUserInfoData['countrySn'] . "\n"); } if ($shippingAddress->isSetPhone()) { //手机 $orderUserInfoData['phone'] = $shippingAddress->getPhone(); //echo ("phone ==== "); //echo ($orderUserInfoData['phone'] . "\n"); } } if ($order->isSetOrderTotal()) { $orderTotal = $order->getOrderTotal(); if ($orderTotal->isSetCurrencyCode()) { //币种 $orderUserInfoData['currency'] = $orderTotal->getCurrencyCode(); //echo ("currency ==== "); //echo ($orderUserInfoData['currency'] . "\n"); } if ($orderTotal->isSetAmount()) { //订单总价,线上总价 $orderData['onlineTotal'] = $orderTotal->getAmount(); $orderData['actualTotal'] = $orderTotal->getAmount(); //echo ("onlineTotal ==== "); //echo ($orderData['onlineTotal'] . "\n"); } } if ($order->isSetNumberOfItemsShipped()) { //echo ("ItemsShipped ==== " . $order->getNumberOfItemsShipped() . "\n"); } if ($order->isSetNumberOfItemsUnshipped()) { //echo ("NumberOfItemsUnshipped ==== " . $order->getNumberOfItemsUnshipped() . "\n"); } if ($order->isSetPaymentExecutionDetail()) { $paymentExecutionDetail = $order->getPaymentExecutionDetail(); $paymentExecutionDetailItemList = $paymentExecutionDetail->getPaymentExecutionDetailItem(); foreach ($paymentExecutionDetailItemList as $paymentExecutionDetailItem) { echo "######PaymentExecutionDetailItem######\n"; if ($paymentExecutionDetailItem->isSetPayment()) { $payment = $paymentExecutionDetailItem->getPayment(); if ($payment->isSetCurrencyCode()) { //echo ("CurrencyCode ==== "); //echo ($payment->getCurrencyCode() . "\n"); } if ($payment->isSetAmount()) { //echo (" Amount ==== "); //echo ($payment->getAmount() . "\n"); } } if ($paymentExecutionDetailItem->isSetSubPaymentMethod()) { //echo ("SubPaymentMethod ==== "); //echo ($paymentExecutionDetailItem->getSubPaymentMethod() . "\n"); } } } if ($order->isSetPaymentMethod()) { $orderExtenData['PaymentMethod'] = $order->getPaymentMethod(); //echo ("PaymentMethod ==== "); //echo ($orderExtenData['PaymentMethod'] . "\n"); } if ($order->isSetMarketplaceId()) { $orderExtenData['MarketplaceId'] = $order->getMarketplaceId(); //echo ("MarketplaceId ==== "); //echo ($orderExtenData['MarketplaceId'] . "\n"); } if ($order->isSetBuyerName()) { //买家ID $orderUserInfoData['platformUsername'] = htmlentities($order->getBuyerName(), ENT_QUOTES); //echo ("platformUsername ==== "); //echo ($orderUserInfoData['platformUsername'] . "\n"); } if ($order->isSetBuyerEmail()) { //买家email $orderUserInfoData['email'] = $order->getBuyerEmail(); //echo ("email ==== "); //echo ($orderUserInfoData['email'] . "\n"); } if ($order->isSetShipmentServiceLevelCategory()) { $orderExtenData['ShipmentServiceLevelCategory'] = $order->getShipmentServiceLevelCategory(); //echo ("ShipmentServiceLevelCategory ==== "); //echo ($orderExtenData['ShipmentServiceLevelCategory'] . "\n"); } //$orderData['ebay_user'] = $user; $orderData['platformId'] = 11; //amazon的平台ID为11 $orderData['accountId'] = $accountId; //amazon的账号ID //echo ("accountId ==== "); //echo ($orderData['accountId'] . "\n"); $orderData['orderAddTime'] = time(); //添加到系统的时间 //echo ("orderAddTime ==== "); //echo ($orderData['orderAddTime'] . "\n"); $orderData['orderStatus'] = C('STATEPENDING'); //默认订单状态 $orderData['orderType'] = C('STATEPENDING_INITIAL'); //默认订单类型 $orderData = array('orderData' => $orderData, 'orderExtenData' => $orderExtenData, 'orderUserInfoData' => $orderUserInfoData); $tName = 'om_unshipped_order'; $where = "WHERE recordNumber='{$orderData['orderData']['recordNumber']}' AND platformId={$orderData['orderData']['platformId']} and is_delete ='0'"; $flagCountUnshipped = OmAvailableModel::getTNameCount($tName, $where); $tName = 'om_shipped_order'; $flagCountshipped = OmAvailableModel::getTNameCount($tName, $where); if (empty($flagCountUnshipped) && empty($flagCountshipped)) { //判断订单是否已经在系统2个订单表(未发货和已发货)中存在 //$orderData['ebay_ordersn'] = generateOrdersn(); $detailrequest = new MarketplaceWebServiceOrders_Model_ListOrderItemsRequest(); $detailrequest->setSellerId(MERCHANT_ID); $detailrequest->setAmazonOrderId($orderData['orderData']['recordNumber']); $orderDetailArr = self::act_invokeListOrderItems($service, $detailrequest); //var_dump($orderDetailArr); exit; for ($i = 0; $i < count($orderDetailArr); $i++) { $orderDetailArr[$i]['orderDetailData']['recordNumber'] = $orderData['orderData']['recordNumber']; } //print_r($orderDetailArr); if (!empty($orderDetailArr)) { $orderData['orderDetail'] = $orderDetailArr; $insertData = array(); //var_dump($obj_order_detail_data); echo "<br>"; $calcInfo = CommonModel::calcAddOrderWeight($orderDetailArr); //计算重量和包材 //var_dump($calcInfo); exit; $orderData['orderData']['ORcalcWeight'] = $calcInfo[0]; $orderData['orderData']['calcWeight'] = $calcInfo[0]; $orderData['orderData']['pmId'] = $calcInfo[1]; if ($orderData['orderData']['calcWeight'] != $totalweight) { $insertData['old_totalweight'] = $totalweight; $insertData['new_totalweight'] = $orderData['orderData']['calcWeight']; } if ($orderData['orderData']['pmId'] != $pmId) { $insertData['old_pmId'] = $pmId; $insertData['new_pmId'] = $orderData['orderData']['pmId']; } $newcarrier = get_carrier($orderData['orderData']['calcWeight'], $orderData['orderUserInfoData']['countryName'], $account, $orderData['orderUserInfoData']['currency']); $orderData['orderData']['transportId'] = $flip_transportList[$newcarrier]; $orderData['orderData']['ORtransportId'] = $flip_transportList[$newcarrier]; $rtn = OldsystemModel::orderErpInsertorder($orderData); //var_dump($rtn); if ($rtn['errcode'] == 200) { //var_dump($rtn); $rtn_data = $rtn['data']; $orderId = $rtn_data['orderId']; $message .= "<font color='green'>" . date("Y-m-d H:i:s") . " 插入老系统成功,订单编号 [{$orderId}] </font><br>"; $pmId = $rtn_data['pmId']; $totalweight = $rtn_data['totalweight']; $shipfee = $rtn_data['shipfee']; $carrier = $rtn_data['carrier']; $carrierId = $rtn_data['carrierId']; $status = $rtn_data['status']; $orderData['orderData']['id'] = $orderId; //赋予新系统订单编号@20140501 if (count($orderData['orderDetail']) > 1) { $orderData['orderData']['orderAttribute'] = 3; } else { if (isset($orderData['orderDetail'][0]['orderDetailData']['amount']) && $orderData['orderDetail'][0]['orderDetailData']['amount'] > 1) { $orderData['orderData']['orderAttribute'] = 2; } } /*$calcShippingInfo = CommonModel :: calcAddOrderShippingFee($orderData,1);//计算运费 //var_dump($calcShippingInfo); exit; //$insert_orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']['fee']; $orderData['orderData']['channelId'] = $calcShippingInfo['fee']['channelId'];*/ $calcShippingInfo = TransAPIModel::trans_carriers_fix_get($orderData['orderData']['transportId'], $orderData['orderData']['calcWeight'], $orderData['orderUserInfoData']['countryName']); //计算运费 //var_dump($calcShippingInfo); $orderData['orderData']['calcShipping'] = $calcShippingInfo['fee']; //$orderData['orderData']['transportId'] = $calcShippingInfo['carrierId']; $orderData['orderData']['channelId'] = $calcShippingInfo['channelId']; $orderData['orderData']['ORchannelId'] = $calcShippingInfo['channelId']; if ($orderData['orderData']['calcShipping'] != $shipfee) { $insertData['old_shippfee'] = $shipfee; $insertData['new_shippfee'] = $orderData['orderData']['calcShipping']; } if ($orderData['orderData']['transportId'] != $carrierId) { $insertData['old_carrierId'] = $carrierId; $insertData['new_carrierId'] = $orderData['orderData']['transportId']; } if (!empty($insertData)) { $insertData['ebay_id'] = $orderId; $insertData['addtime'] = time(); //var_dump($insertData); OldsystemModel::insertTempSyncRecords($insertData); // 插入临时对比记录表 } $orderData = AutoModel::auto_contrast_intercept($orderData); //print_r($interceptInfo); exit; /*$orderData['orderData']['orderStatus'] = $interceptInfo['orderStatus']; $orderData['orderData']['orderType'] = $interceptInfo['orderType'];*/ //var_dump($orderData); exit; if (OrderAddModel::insertAllOrderRow($orderData)) { //echo 'insert success!' . "\n"; $message .= "<font color='green'>" . date("Y-m-d H:i:s") . ", 新增订单{$orderData['orderData']['recordNumber']}成功</font><br>"; } else { $message .= "<font color='red'>" . date("Y-m-d H:i:s") . ", 新增订单{$orderData['orderData']['recordNumber']}失败</font><br>"; //echo OrderAddModel :: $errMsg; } } } else { //echo "Amazon ID: ".$orderData['recordnumber']." 订单详情添加失败\n"; $message .= "<font color='red'>Amazon ID: " . $orderData['orderData']['recordNumber'] . " has no detail </font><br>"; } } else { $message .= "<font color='red'>Amazon ID: " . $orderData['orderData']['recordNumber'] . " had exist</font><br>"; } } } } } catch (MarketplaceWebServiceOrders_Exception $ex) { $message .= "Caught Exception: " . $ex->getMessage() . "<br>"; $message .= "Response Status Code: " . $ex->getStatusCode() . "<br>"; $message .= "Error Code: " . $ex->getErrorCode() . "<br>"; $message .= "Error Type: " . $ex->getErrorType() . "<br>"; $message .= "Request ID: " . $ex->getRequestId() . "<br>"; $message .= "XML: " . $ex->getXML() . "<br>"; } catch (Exception $e) { BaseModel::rollback(); BaseModel::autoCommit(); $message .= $e->getMessage() . "<br>"; } return $message; }
public function act_shiftLibrary() { $sku = trim($_POST['sku']); $sku = get_goodsSn($sku); $oldposition = trim($_POST['oldposition']); $newposition = trim($_POST['newposition']); $nums = intval(trim($_POST['nums'])); if (empty($sku)) { self::$errCode = 401; self::$errMsg = "sku不能为空"; return false; } if (empty($oldposition)) { self::$errCode = 402; self::$errMsg = "旧仓位号不能为空"; return false; } if (empty($newposition)) { self::$errCode = 403; self::$errMsg = "新仓位号不能为空"; return false; } if ($oldposition == $newposition) { self::$errCode = 404; self::$errMsg = "新旧仓位号不能相同"; return false; } $where = " where sku = '{$sku}'"; $skuinfo = whShelfModel::selectSku($where); if (empty($skuinfo)) { self::$errCode = 404; self::$errMsg = "无该料号信息"; return false; } else { $skuId = $skuinfo['id']; } $old_positon_info = OmAvailableModel::getTNameList("wh_position_distribution", "id", "where pName='{$oldposition}' and storeId in(1,2)"); if (empty($old_positon_info)) { self::$errCode = 405; self::$errMsg = "无旧仓位号信息"; return false; } else { $old_location = $old_positon_info[0]['id']; } $new_positon_info = OmAvailableModel::getTNameList("wh_position_distribution", "id,type", "where pName='{$newposition}' and storeId in(1,2)"); if (empty($new_positon_info)) { self::$errCode = 406; self::$errMsg = "无新仓位号信息"; return false; } else { $new_location = $new_positon_info[0]['id']; } $old_sku_pos_info = OmAvailableModel::getTNameList("wh_product_position_relation", "*", "where pId='{$skuId}' and positionId='{$old_location}' and storeId in(1,2) and is_delete=0"); if (empty($old_sku_pos_info)) { self::$errCode = 407; self::$errMsg = "无sku对应的旧仓位号信息"; return false; } $new_sku_pos_info = OmAvailableModel::getTNameList("wh_product_position_relation", "*", "where pId='{$skuId}' and positionId='{$new_location}' and storeId in(1,2) and is_delete=0"); if ($nums > $old_sku_pos_info[0]['nums'] || empty($nums)) { $change_nums = $old_sku_pos_info[0]['nums']; } else { $change_nums = $nums; } OmAvailableModel::begin(); if (!empty($new_sku_pos_info)) { if (empty($nums)) { $tname_old = "wh_product_position_relation"; $set_old = "set nums=0,is_delete=1"; $where_old = "where id={$old_sku_pos_info[0]['id']}"; $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old); if (!$update_old) { self::$errCode = 408; self::$errMsg = "更新旧仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } else { $tname_old = "wh_product_position_relation"; $set_old = "set nums=nums-{$change_nums}"; $where_old = "where id={$old_sku_pos_info[0]['id']}"; $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old); if (!$update_old) { self::$errCode = 409; self::$errMsg = "更新旧仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } $tname_new = "wh_product_position_relation"; $set_new = "set nums=nums+{$change_nums}"; $where_new = "where id={$new_sku_pos_info[0]['id']}"; $update_new = OmAvailableModel::updateTNameRow($tname_new, $set_new, $where_new); if (!$update_new) { self::$errCode = 410; self::$errMsg = "更新新仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } else { if (empty($nums)) { $tname_old = "wh_product_position_relation"; $set_old = "set nums=0,is_delete=1"; $where_old = "where id={$old_sku_pos_info[0]['id']}"; $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old); if (!$update_old) { self::$errCode = 411; self::$errMsg = "更新旧仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } else { $tname_old = "wh_product_position_relation"; $set_old = "set nums=nums-{$change_nums}"; $where_old = "where id={$old_sku_pos_info[0]['id']}"; $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old); if (!$update_old) { self::$errCode = 412; self::$errMsg = "更新旧仓位库存失败!"; TransactionBaseModel::rollback(); return false; } } $tname_insert = "wh_product_position_relation"; $set_insert = "set pId='{$skuId}',positionId='{$new_location}',nums='{$change_nums}',type={$new_positon_info[0]['type']}"; $relation_insert = OmAvailableModel::insertRow($tname_insert, $set_insert); if (!$relation_insert) { self::$errCode = 413; self::$errMsg = "插入关系表失败!"; TransactionBaseModel::rollback(); return false; } /* //更新仓位使用状态 $update_position = OmAvailableModel::updateTNameRow("wh_position_distribution","set is_enable=1","where id=$new_location"); if(!$update_position){ self::$errCode = 414; self::$errMsg = "更新仓位使用状态失败!"; TransactionBaseModel :: rollback(); return false; } */ } //全部转移到新仓位,则将仓位同步到老ERP if (!$nums) { $info = CommonModel::updateSkuLocation($sku, $newposition); //print_r($info);exit; if ($info['res_code'] != 200) { self::$errCode = 414; self::$errMsg = '同步旧ERP仓位失败!'; return FALSE; } } OmAvailableModel::commit(); self::$errMsg = "料号[{$sku}]移库成功!"; return true; }
public function view_updateInputOn() { $id = $_GET['id']; $inputName = $_GET['inputName'] ? post_check(trim($_GET['inputName'])) : ''; $textStatus = $_GET['textStatus'] ? post_check(trim($_GET['textStatus'])) : ''; $pid = $_GET['pid'] ? post_check(trim($_GET['pid'])) : ''; if (intval($id) == 0) { $status = "属性Id错误"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } if (intval($textStatus) <= 0) { $status = "文本方式有误"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } if (empty($inputName)) { $tName = 'pc_archive_spu_input_value_relation'; $where = "WHERE inputId={$id}"; $countIN = OmAvailableModel::getTNameCount($tName, $where); if ($countIN) { $status = "该属性已经绑定了SPU,不能删除"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } $tName = 'pc_archive_input'; $where = "WHERE id={$id}"; OmAvailableModel::deleteTNameRow($tName, $where); $status = "删除成功"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } if (empty($pid)) { $status = "类型不能为空"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } $tName = 'pc_archive_input'; $select = '*'; $where = "WHERE id='{$id}'"; $inputList = OmAvailableModel::getTNameList($tName, $select, $where); if (empty($inputList)) { $status = "不存在该属性记录"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } $categoryName = getAllCateNameByPath($pid); $pathImplodeStr = getAllPathBypid($pid); $pathImplodeStr = getAllPathBypid($pid); $i = strrpos($pathImplodeStr, ','); if ($i !== false) { $pathImplodeStr = substr($pathImplodeStr, 0, $i); } $where = "WHERE inputName='{$inputName}' and categoryPath IN ({$pathImplodeStr}) and id<>{$id}"; $count = OmAvailableModel::getTNameCount($tName, $where); if ($count) { $status = "{$categoryName} 或其父类下已经存在 {$inputName} 属性"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } $set = "SET inputName='{$inputName}',categoryPath='{$pid}',textStatus='{$textStatus}'"; $where = "WHERE id='{$id}'"; $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where); if (!$affectRow) { $status = "无数据修改"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); exit; } $categoryName1 = getAllCateNameByPath($inputList[0]['categoryPath']); $categoryName2 = getAllCateNameByPath($pid); $status = "{$categoryName1} 下 {$inputList[0]['inputName']} 修改为 {$categoryName2} 下 {$inputName} 成功"; header("Location:index.php?mod=property&act=getInputList&status={$status}"); }
<?php error_reporting(E_ALL); header("Content-type: text/html; charset=utf-8"); date_default_timezone_set('Asia/Shanghai'); require "/data/web/qc.valsun.cn/framework.php"; Core::getInstance(); $now = time(); $weekago = $now - 7 * 24 * 3600; $where = " where printTime < {$weekago} and (getUserId is null OR getUserId = 0) AND is_delete=0"; $records = OmAvailableModel::getTNameList("qc_sample_info", "*", $where); if ($records) { echo date('Y-m-d H:i:s', $now) . "共有" . count($records) . "条记录需要删除!\n"; $info = OmAvailableModel::updateTNameRow("qc_sample_info", "set is_delete=1", $where); if ($info) { echo "删除成功!\n"; } else { echo "删除失败!\n"; } } else { echo date('Y-m-d H:i:s', $now) . "没有超过一周的无用记录!\n"; }
function act_delProductsCategoryAppoint() { $id = intval($_POST['id']); if ($id <= 0) { self::$errCode = '101'; self::$errMsg = '无效记录,删除失败'; return false; } $tName = 'pc_products_large_category_appoint'; $where = "WHERE id={$id}"; $set = "SET is_delete=1"; OmAvailableModel::updateTNameRow($tName, $set, $where); self::$errCode = '200'; self::$errMsg = '删除成功'; return true; }
function act_ebayRequestUpdate() { $successNum = 0; $errordetail = NULL; include WEB_PATH . "lib/feedback/ebaylibrary/ebay_config.php"; $verb = 'GetFeedback'; $ebayUserId = isset($_POST['user_id']) ? $_POST['user_id'] : ''; $account = isset($_POST['ebay_account']) ? $_POST['ebay_account'] : ""; $select = " `id` "; $where = " where `modifyStatus`=0 and `is_delete`=0 and ebayUserId='{$ebayUserId}' and `account`='{$account}' "; $info = EbayFeedbackModel::getRequestChangeList($select, $where); //获取请求修改列表 foreach ($info as $value) { $id = $value['id']; $select = " `token` "; $where = "\twhere `account` = '{$account}' "; $token = AccountModel::getAccountList($select, $where); $token = $token[0]['token']; $select = " `FeedbackID`,`CommentText`,`CommentingUser`,`ItemID`,`TransactionID`,`CommentType` "; $where = " where account='{$account}' and CommentingUser ='******' "; //and (CommentType='Neutral' or CommentType='Negative') $get_info = EbayFeedbackModel::getOrderList($select, $where); //卖家评价信息 //var_dump($get_info); foreach ($get_info as $v) { $status = ""; $feedbackID = $v['FeedbackID']; $commentingUser = $v['CommentingUser']; $itemID = $v['ItemID']; $transactionID = $v['TransactionID']; $commentType = $v['CommentType']; $commentText = $v['CommentText']; $transactionID = html_entity_decode($transactionID); $transactionID = trim($transactionID, "´"); //var_dump($transactionID); $requestXmlBody = '<?xml version="1.0" encoding="utf-8"?> <GetFeedbackRequest xmlns="urn:ebay:apis:eBLBaseComponents"> <RequesterCredentials> <eBayAuthToken>' . $token . '</eBayAuthToken> </RequesterCredentials> <ItemID>' . $itemID . '</ItemID> <TransactionID>' . $transactionID . '</TransactionID> <UserID>' . $commentingUser . '</UserID> <FeedbackType>FeedbackReceived</FeedbackType> <DetailLevel>ReturnAll</DetailLevel> </GetFeedbackRequest>'; $session = new eBaySession($token, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb); $responseXml = $session->sendHttpRequest($requestXmlBody); if (stristr($responseXml, 'HTTP 404') || $responseXml == '') { self::$errCode = '002'; self::$errMsg = "拉取eaby feedback 失败"; return 'id not found'; } $data = XML_unserialize($responseXml); //print_r($responseXml);exit; $ack = $data['GetFeedbackResponse']['Ack']; $feedbackRevised = $data['GetFeedbackResponse']['FeedbackDetailArray']['FeedbackDetail']; //print_r($feedbackRevised); $feedbackRevised = $feedbackRevised[0]['FeedbackRevised']; if ($ack != "Success") { self::$errCode = '002'; self::$errMsg = "拉取eaby feedback 失败"; return false; } else { //var_dump($data,$feedbackRevised);exit; /* if(1 == "true") { */ $feedback = $data['GetFeedbackResponse']['FeedbackDetailArray']['FeedbackDetail']; $feedbackType = isset($feedback[0]['CommentType']) ? $feedback[0]['CommentType'] : $feedback['CommentType']; $feedbackUser = $feedback[0]['CommentingUser']; if ($commentingUser == $feedbackUser) { $feedbackText = addslashes(str_rep($feedback[0]['CommentText'])); } else { $feedbackText = addslashes(str_rep($commentText)); } $status = ""; if ($commentType != $feedbackType && $feedbackType) { if ($commentType == "Neutral") { if ($feedbackType == "Positive") { $status = "21"; //中评改好评 } else { if ($feedbackType == "Negative") { $status = "23"; //中评改差评 } else { $status = "22"; //中评改中评 } } } else { if ($commentType == "Negative") { if ($feedbackType == "Positive") { $status = "31"; } else { if ($feedbackType == "Neutral") { $status = "32"; } else { $status = "33"; } } } else { } } //好评情况不做处理 if ($status != "") { $tName = " fb_comment_record_ebay "; $set = " set status='{$status}',CommentType='{$feedbackType}',CommentText='{$feedbackText}'"; $where = " where FeedbackID='{$feedbackID}' "; $sql = "{$tName} {$set} {$where} "; //echo $sql."\n"; if (OmAvailableModel::updateTNameRow($tName, $set, $where)) { $tName = " fb_request_change_ebay "; $set = " set modifyStatus=1 "; $where = " where id ={$id} "; $sql = "{$tName} {$set} {$where}"; $res = OmAvailableModel::updateTNameRow($tName, $set, $where); if ($res) { $successNum += 1; //self::$errMsg = "修改成功"; } else { /* self::$errCode = '002'; self::$errMsg = "更新状态失败$sql"; */ } } else { //echo 'Failure '."\n"; /* self::$errCode = '002'; self::$errMsg = "更新评价失败!"; */ } //echo 'userID :'.$commentingUser.":".$commentType."------------>".$feedbackType."\n"; } /* else{ self::$errCode = '002'; self::$errMsg = "客户评价没有修改!"; return false; } */ } else { //end if线上评价与本地评价不同 $errordetail .= "{$commentingUser} "; } /* }else{//end feedbackRevised =ture self::$errCode = '002'; self::$errMsg = "客户还没有修改评价!"; return false; } */ } //end of 获取ebay feedback接口成功 } /* self::$errCode = '002'; self::$errMsg = "$ebayUserId $account 系统不存此评价信息"; return false; */ } //foreach if ($successNum > 0) { self::$errMsg = "修改成功{$successNum}个"; return true; } else { self::$errCode = '002'; self::$errMsg = "{$errordetail} 还未修改评价"; return false; } }
public function view_index() { /*$OmAccountAct = new OmAccountAct(); $ebayAccountList = $OmAccountAct->act_getEbayAccountList(); print_r($ebayAccountList);*/ //print_r($_SESSION); $orderid = isset($_GET['orderid']) ? $_GET['orderid'] : ""; if (isset($_POST['orderid'])) { $orderid = $_POST['orderid']; $where = " where omOrderId ={$orderid}"; $details = OmAvailableModel::getTNameList("om_unshipped_order_detail", "*", $where); $order = OmAvailableModel::getTNameList("om_unshipped_order", "*", "where id={$orderid}"); $accountId = $order[0]['accountId']; $message = ""; foreach ($details as $detail) { $sql_arr = array(); $sql_arr['omOrderId'] = $orderid; $sql_arr['sku'] = $detail['sku']; $sql_arr['amount'] = $detail['amount']; $sql_arr['accountId'] = $accountId; $app = $detail['sku'] . "*app"; $reason1 = $detail['sku'] . "*reason1"; $reason2 = $detail['sku'] . "*reason2"; $remark = $detail['sku'] . "*remark"; $sql_arr['type'] = $_POST[$app]; $sql_arr['reason1'] = $_POST[$reason1]; $sql_arr['reason2'] = $_POST[$reason2]; $sql_arr['remark'] = $_POST[$remark]; $sql_arr['userId'] = $_SESSION['sysUserId']; $sql_arr['createdTime'] = time(); if ($sql_arr['type'] == "" && $sql_arr['reason1'] == "" && $sql_arr['reason2'] == "" && $sql_arr['remark'] == "") { continue; } elseif ($sql_arr['type'] != "" && ($sql_arr['reason1'] != "" || $sql_arr['reason2'] != "")) { $set = array2sql($sql_arr); $where = " where omOrderId={$orderid} and sku='{$detail['sku']}'"; $order_appraise = OmAvailableModel::getTNameList("om_order_detail_appraisal", "*", $where); if ($order_appraise) { $msg = OmAvailableModel::updateTNameRow("om_order_detail_appraisal", " set " . $set, $where); if (!$msg) { $message .= "<font color='red'>料号{$detail['sku']}数据保存失败!</font><br>"; } else { $message .= "<font color='green'>料号{$detail['sku']}数据保存成功!</font><br>"; } } else { $msg = OmAvailableModel::insertRow("om_order_detail_appraisal", " set " . $set); if (!$msg) { $message .= "<font color='red'>料号{$detail['sku']}数据保存失败!</font><br>"; } else { $message .= "<font color='green'>料号{$detail['sku']}数据保存成功!</font><br>"; } } } else { $message .= "<font color='red'>请将料号{$detail['sku']}的数据填写完整!</font><br>"; } } $this->smarty->assign("message", $message); } $where = " where omOrderId ={$orderid}"; $details = OmAvailableModel::getTNameList("om_unshipped_order_detail", "*", $where); $reasons = OmAvailableModel::getTNameList("om_order_refund_reason", "*", " where typeId=3"); $reason = array(); foreach ($reasons as $value) { $reason[$value['id']] = $value['reason']; } $appraise = array(); $i = 0; foreach ($details as $detail) { $where = " where omOrderId={$orderid} and sku='{$detail['sku']}'"; $order_appraise = OmAvailableModel::getTNameList("om_order_detail_appraisal", "*", $where); if ($order_appraise) { foreach ($order_appraise as $key => $value) { $appraise[$i]['reason1'] = $value['reason1']; $appraise[$i]['reason2'] = $value['reason2']; $appraise[$i]['type'] = $value['type']; $appraise[$i]['sku'] = $detail['sku']; $appraise[$i]['remark'] = $value['remark']; } } else { $appraise[$i]['reason1'] = ""; $appraise[$i]['reason2'] = ""; $appraise[$i]['type'] = ""; $appraise[$i]['sku'] = $detail['sku']; $appraise[$i]['remark'] = ""; } $i++; } //print_r($appraise); $this->smarty->assign("skuinfoList", $appraise); $this->smarty->assign("reasonList", $reason); $this->smarty->assign("orderid", $orderid); $this->smarty->assign("ebayAccountList", $ebayAccountList); $this->smarty->assign('toptitle', '添加B2B中差评'); $this->smarty->display("negativeFeedback.htm"); }
public function act_adjustPrintNum() { $printBatch = isset($_POST['printBatch']) ? $_POST['printBatch'] : ""; $num = isset($_POST['num']) ? $_POST['num'] : ""; if ($printBatch == "") { self::$errCode = 101; self::$errMsg = '批次号不能为空!'; return false; } if (!is_numeric($num) || $num) { self::$errCode = 101; self::$errMsg = '参数num异常!'; return false; } $where = "where printBatch='{$printBatch}'"; $record = OmAvailableModel::getTNameList("qc_sample_info", "*", $where); if ($record[0]['detectStatus'] == 3) { $set = "set printNum=printNum+{$num},ichibanNum=ichibanNum+{$num}"; } $set = "set printNum=printNum+{$num}"; $info = OmAvailableModel::updateTNameRow("qc_sample_info", $set, $where); if (!$info) { self::$errCode = 101; self::$errMsg = '修改失败!'; return false; } else { self::$errCode = 200; self::$errMsg = '修改成功!'; return true; } }
public function view_productsCombineSpuBack() { $combineSpu = $_GET['combineSpu'] ? $_GET['combineSpu'] : ''; $id = $_GET['id'] ? $_GET['id'] : ''; $userId = $_SESSION['userId']; $now = time(); if (intval($userId) <= 0) { $status = "未登录"; header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}"); exit; } if (empty($id)) { $status = "id为空"; header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}"); exit; } $idArr = array_filter(explode(',', $id)); foreach ($idArr as $value) { if (intval($value) <= 0) { $status = "含有非法id"; header("Location:index.php?mod=products&act=getProductsCombineSpuTakeList&status={$status}&combineSpu={$combineSpu}"); exit; } } $newIdArr = implode(',', $idArr); $tName = 'pc_spu_web_maker'; $set = "SET isTake=0"; $where = "WHERE id in({$newIdArr})"; OmAvailableModel::updateTNameRow($tName, $set, $where); $status = "退还料号成功"; header("Location:index.php?mod=products&act=getProductsCombineSpuList&status={$status}&combineSpu={$combineSpu}"); }
public function view_addCombineOn() { $combineSpu = $_POST['combineSpu'] ? post_check(trim($_POST['combineSpu'])) : ''; if (empty($combineSpu)) { $status = "空的SPU"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } if (intval($_SESSION['userId']) <= 0) { $status = "登陆超时!"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } $tName = 'pc_auto_create_spu'; $select = 'status'; $where = "WHERE spu='{$combineSpu}' and is_delete=0"; $autoSpuList = OmAvailableModel::getTNameList($tName, $select, $where); if (empty($autoSpuList)) { $status = "自动生成SPU列表中不存在 {$combineSpu}"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } $amount = $_POST['amount'] ? post_check(trim($_POST['amount'])) : 0; $amount = intval($amount); if ($amount <= 0 || $amount > 500) { $status = "数量必须在1-500之间"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } $tName = 'pc_goods_combine'; $where = "WHERE is_delete=0 AND combineSpu='{$combineSpu}'"; $countComSpu = OmAvailableModel::getTNameCount($tName, $where); $tmpArr = array(); for ($index = 0; $index <= $amount; $index++) { $combineSku = $_POST['combineSku' . $index] ? post_check(trim($_POST['combineSku' . $index])) : ''; $combineSku = $combineSpu . $combineSku; if ($index == 0 && $countComSpu > 0 && $combineSku == $combineSpu) { $status = "存在为空的子料号,请检查!"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } if ($index > 0 && $combineSku == $combineSpu) { //只可能index=0时候,$combineSku==$combineSpu,其他表示无效 continue; } $combineLength = $_POST['combineLength' . $index] ? post_check(trim($_POST['combineLength' . $index])) : ''; $combineWidth = $_POST['combineWidth' . $index] ? post_check(trim($_POST['combineWidth' . $index])) : ''; $combineHeight = $_POST['combineHeight' . $index] ? post_check(trim($_POST['combineHeight' . $index])) : ''; $combineNote = $_POST['combineNote' . $index] ? trim($_POST['combineNote' . $index]) : ''; $skuArr = $_POST['sku' . $index]; $countArr = $_POST['count' . $index]; if (strlen($combineSku) > 30) { $status = "{$combineSku} 字符长度大于30,错误!"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } if (!preg_match("/^{$combineSpu}(_[A-Z0-9]+)*\$/", $combineSku)) { $status = "{$combineSku} 不规范,请检查格式是否正确"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } if ($combineSku == $combineSpu && $amount > 1) { $status = "存在SKU为空的参数"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } $tmpArr[] = $combineSku; if (!empty($combineLength)) { if (!is_numeric($combineLength) || $combineLength < 0) { $status = "{$combineSku} 长度必须为数字"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } } if (!empty($combineWidth)) { if (!is_numeric($combineWidth) || $combineWidth < 0) { $status = "{$combineSku} 宽度必须为数字"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } } if (!empty($combineHeight)) { if (!is_numeric($combineHeight) || $combineHeight < 0) { $status = "{$combineSku} 高度必须为数字"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } } if (empty($skuArr[0]) || empty($countArr[0])) { $status = "{$combineSku} 至少要包含一条不为空的真实料号对应记录"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } $tName = 'pc_goods_combine'; $where = "WHERE combineSku='{$combineSku}' and is_delete=0"; $count = OmAvailableModel::getTNameCount($tName, $where); if ($count) { $status = "{$combineSku} 已经存在"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } if (count($skuArr) != count(array_unique($skuArr))) { $status = "{$combineSku} 中存在重复的真实料号,请检查"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } $tName = 'pc_goods'; foreach ($skuArr as $value) { if (!empty($value)) { $where = "WHERE sku='{$value}' and is_delete=0"; $count = OmAvailableModel::getTNameCount($tName, $where); if (!$count) { $status = "{$combineSku} 真实料号 {$value} 不存在"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } } } foreach ($countArr as $value) { if (intval($value) <= 0) { $status = "{$combineSku} 对应真实料号的数量有误"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } } } $tmpArr = array_filter($tmpArr); if (count($tmpArr) != count(array_unique($tmpArr))) { $status = "存在重复的虚拟子料号,请检查!"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; exit; } try { $ebayGoodsArr = array(); //同步数据数组 BaseModel::begin(); for ($index = 0; $index <= $amount; $index++) { $combineSku = $_POST['combineSku' . $index] ? post_check(trim($_POST['combineSku' . $index])) : ''; $combineSku = $combineSpu . $combineSku; if ($index > 0 && $combineSku == $combineSpu) { //只可能index=0时候,$combineSku==$combineSpu,其他表示无效 continue; } $combineLength = $_POST['combineLength' . $index] ? post_check(trim($_POST['combineLength' . $index])) : ''; $combineWidth = $_POST['combineWidth' . $index] ? post_check(trim($_POST['combineWidth' . $index])) : ''; $combineHeight = $_POST['combineHeight' . $index] ? post_check(trim($_POST['combineHeight' . $index])) : ''; $combineNote = $_POST['combineNote' . $index] ? trim($_POST['combineNote' . $index]) : ''; $skuArr = $_POST['sku' . $index]; $countArr = $_POST['count' . $index]; $dataCom = array(); $dataCom['combineSpu'] = $combineSpu; $dataCom['combineSku'] = $combineSku; $dataCom['combineCost'] = $combineCost; $dataCom['combineWeight'] = $combineWeight; $dataCom['combineLength'] = $combineLength; $dataCom['combineWidth'] = $combineWidth; $dataCom['combineHeight'] = $combineHeight; $dataCom['combineNote'] = $combineNote; $dataCom['combineUserId'] = $_SESSION['userId']; $dataCom['addTime'] = time(); $tName = 'pc_goods_combine'; $insertIdCom = OmAvailableModel::addTNameRow2arr($tName, $dataCom); if (!$insertIdCom) { throw new Exception('add combine error'); } $dataRelation = array(); $dataRelationMem = array(); for ($i = 0; $i < count($skuArr); $i++) { if (!empty($skuArr[$i]) && !empty($countArr[$i])) { $dataRelation[] = array('combineSku' => $combineSku, 'sku' => $skuArr[$i], 'count' => $countArr[$i]); $dataRelationMem[] = array('sku' => $skuArr[$i], 'count' => $countArr[$i]); } } if (!empty($dataRelation)) { $tName = 'pc_sku_combine_relation'; $where = "WHERE combineSku='{$combineSku}'"; $dataRelationCount = OmAvailableModel::getTNameCount($tName, $where); if ($dataRelationCount) { OmAvailableModel::deleteTNameRow($tName, $where); } foreach ($dataRelation as $value) { if (!empty($value['combineSku']) && !empty($value['sku']) && !empty($value['count'])) { $insertId = OmAvailableModel::addTNameRow2arr($tName, $value); } } } if ($autoSpuList[0]['status'] != 2) { $tName = 'pc_auto_create_spu'; $set = "SET status=2"; $where = "WHERE spu='{$combineSpu}'"; $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where); } //将新添加的sku添加到mem中 $key = 'pc_goods_combine_' . $combineSku; $dataCom['detail'] = $dataRelationMem; $value = $dataCom; setMemNewByKey($key, $value); //这里不保证能添加成功 //同步新数据到旧系统中 $ebayProductsCombine = array(); $ebayProductsCombine['id'] = $insertIdCom; $ebayProductsCombine['goods_sn'] = $combineSku; $goods_sncombine = array(); $truesku = array(); foreach ($dataRelationMem as $value) { $str = ''; $strTrue = ''; $str = $value['sku'] . '*' . $value['count']; $strTrue = '[' . $value['sku'] . ']'; $goods_sncombine[] = $str; $truesku[] = $strTrue; } $ebayProductsCombine['goods_sncombine'] = implode(',', $goods_sncombine); $ebayProductsCombine['notes'] = $combineNote; $ebayProductsCombine['goods_price'] = $combineCost; $ebayProductsCombine['goods_weight'] = $combineWeight; $ebayProductsCombine['cguser'] = getPersonNameById($_SESSION['userId']); $ebayProductsCombine['ebay_user'] = '******'; $ebayProductsCombine['createdtime'] = time(); $ebayProductsCombine['truesku'] = implode(',', $truesku); $ebayGoodsArr[] = $ebayProductsCombine; } BaseModel::commit(); BaseModel::autoCommit(); addSalerInfoForAny($combineSpu, 2, $_SESSION['userId'], $_SESSION['userId']); //add by zqt 20140519,添加销售人逻辑 //同步数据到深圳ERP foreach ($ebayGoodsArr as $value) { $ret = OmAvailableModel::newData2ErpInterfOpen('pc.erp.addGoodsCombine', $value, 'gw88'); } $status = "添加成功"; echo '<script language="javascript"> alert("' . $status . '"); window.parent.location.href = "index.php?mod=goods&act=getCombineList&searchComField=1&fieldValue=' . $combineSpu . '"; </script>'; exit; } catch (Exception $e) { BaseModel::rollback(); BaseModel::autoCommit(); echo $e->getMessage(); $status = "添加失败,请联系系统技术部,谢谢"; echo '<script language="javascript"> alert("' . $status . '"); </script>'; } }
public function view_printGroupOrder2() { $groupsn = isset($_GET['groupsn']) ? trim($_GET['groupsn']) : 0; if (empty($groupsn)) { echo "请指定配货清单!"; exit; } $group_list = OmAvailableModel::getTNameList("wh_shipping_order_group", "*", "where shipOrderGroup='{$groupsn}' order by id asc"); if (!$group_list) { echo "该配货清单不存在!"; exit; } $time = time(); $userName = $_SESSION['userName']; //更新今日清单打印表 OmAvailableModel::updateTNameRow("wh_shipping_order_group_print", "set status='1',orderPrintUser='******',orderPrintTime='{$time}'", "where shipOrderGroup='{$groupsn}'"); //获取订单对应的车号 $orderids = array(); foreach ($group_list as $group) { if (!isset($orderids[$group['shipOrderId']])) { $orderids[$group['shipOrderId']] = $group['carNumber']; } } $o_arr = array(); foreach ($orderids as $order => $car_number) { $o_arr[] = $order; } $oids = implode(',', $o_arr); $po_obj = new PackingOrderModel(); $ordersinfo = $po_obj->getaSetOfOrderInfo($oids); if (empty($ordersinfo)) { $data = array('data' => array('没有可打印内容!'), 'link' => 'index.php?mod=orderWaitforPrint&act=printList'); goErrMsgPage($data); exit; } $sod_obj = new ShipingOrderDetailModel(); $acc_id_arr = array(); foreach ($ordersinfo as &$orinfval) { $locationinfo = array(); $totalnum = 0; $package_type = ''; $iscard = ''; $skulisttemp = $sod_obj->getAllSkuListByOrderId($orinfval['id'], "order by pName,combineSku"); $totalnum = $skulisttemp['totalnum']; $locationinfo = $skulisttemp['skuinfo']; if (isset($locationinfo['notcombine']) && count($locationinfo['notcombine']['info']) == 1) { $package_type = $skulisttemp['packagetype']; } $iscard = printLabelModel::checkprintcard($orinfval['id']); $pmNameStr = CommonModel::getMaterInfoById($orinfval['pmId']); $orinfval['finalposition'] = $locationinfo; $totalStr = $totalnum . " " . $pmNameStr . " " . $orinfval['calcWeight'] . "KG"; if (!empty($package_type)) { $totalStr = $totalStr . " " . $package_type; } if (!empty($iscard)) { $totalStr = $totalStr . " " . $iscard; } $totalStr = $totalStr . " " . $orinfval['platformUsername']; $carrier = CommonModel::getShipingNameById($orinfval['transportId']); $orinfval['abbrshipname'] = CommonModel::getShipingAbbrNameById($orinfval['transportId']); $orinfval['totalStr'] = $totalStr; $orinfval['notes'] = $po_obj->getOrderNotesInfo($orinfval['id']); $orinfval['countryZh'] = CommonModel::getCountryNameCn($orinfval['countryName']); $orinfval['partionFromAddress'] = printLabelModel::getPartionFromAddress($orinfval['id'], $carrier, $orinfval['countryName']); if (!in_array($orinfval['accountId'], $acc_id_arr)) { array_push($acc_id_arr, $orinfval['accountId']); } } $salesaccountinfo = CommonModel::getAccountInfo($acc_id_arr); $this->smarty->assign('salesaccountinfo', $salesaccountinfo); $totalCount = count($ordersinfo); $this->smarty->assign('totalCount', $totalCount); $this->smarty->assign('orderids', $orderids); $this->smarty->assign('ordersinfo', $ordersinfo); $this->smarty->display('label50x100_22.htm'); }
public function act_modifyOrder() { if (isset($_POST) && !empty($_POST)) { //$OrderModifyAct->act_modifyOrder(); $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : ''; $ostatus = isset($_POST['edit_ostatus']) ? $_POST['edit_ostatus'] : $_POST['ostatus']; $otype = isset($_POST['edit_otype']) ? $_POST['edit_otype'] : $_POST['otype']; $update_order = array(); $update_userinfo = array(); $update_tracknumber = array(); //$orderid = $_POST['orderid']; //var_dump($_POST); exit; $updatestatus = false; if (!empty($_POST['data'])) { $data = $_POST['data']; } if (isset($data['username'])) { $update_userinfo['username'] = $data['username']; } if (isset($data['orderStatus'])) { $update_order['orderStatus'] = $data['orderStatus']; } if (isset($data['orderType'])) { $update_order['orderType'] = $data['orderType']; $updatestatus = true; } if (isset($data['street'])) { $update_userinfo['street'] = $data['street']; } if (isset($data['platformUsername'])) { $update_userinfo['platformUsername'] = $data['platformUsername']; } if (isset($data['address2'])) { $update_userinfo['address2'] = $data['address2']; } if (isset($data['actualShipping'])) { $update_order['actualShipping'] = $data['actualShipping']; } if (isset($data['city'])) { $update_userinfo['city'] = $data['city']; } if (isset($data['state'])) { $update_userinfo['state'] = $data['state']; } if (isset($data['countryName'])) { $update_userinfo['countryName'] = $data['countryName']; } if (isset($data['zipCode'])) { $update_userinfo['zipCode'] = $data['zipCode']; } if (isset($data['landline'])) { $update_userinfo['landline'] = $data['landline']; } if (isset($data['phone'])) { $update_userinfo['phone'] = $data['phone']; } if (isset($data['transportId'])) { $update_order['transportId'] = $data['transportId']; } if (isset($data['update_notes'])) { $update_note = $data['update_notes']; } if (isset($data['note_new'])) { $add_note = $data['note_new']; } if ($data['edit_tracknumber']) { $update_tracknumber['omOrderId'] = $orderid; $update_tracknumber['tracknumber'] = $data['edit_tracknumber']; $update_tracknumber['addUser'] = $_SESSION['sysUserId']; $update_tracknumber['createdTime'] = time(); //var_dump($update_tracknumber); exit; } BaseModel::begin(); //开始事务 if ($update_order) { //$sql = "UPDATE om_unshipped_order set ".array2sql($update_order)." WHERE id = ".$orderid; //$msg = commonModel::orderLog($orderid,$update_order['orderStatus'],$update_order['orderType'],$sql); if (OrderindexModel::updateOrder('om_unshipped_order', $update_order, ' WHERE id = ' . $orderid)) { if ($updatestatus) { $ProductStatus = new ProductStatus(); if (!$ProductStatus->updateSkuStatusByOrderStatus(array($orderid), $batch_ostatus_val, $batch_otype_val)) { BaseModel::rollback(); } } $modify_showerrorinfo = "<font color='green'>更新成功</font>"; } else { self::$errCode = "001"; self::$errMsg = "更新订单信息失败!"; BaseModel::rollback(); return false; } } if ($update_userinfo) { //var_dump($update_userinfo); if (OrderindexModel::updateOrder('om_unshipped_order_userInfo', $update_userinfo, ' WHERE omOrderId = ' . $orderid)) { $modify_showerrorinfo = "<font color='green'>更新成功</font>"; } else { self::$errCode = "002"; self::$errMsg = "更新订单用户信息失败!"; BaseModel::rollback(); return false; } } if ($update_tracknumber) { //echo $msg; if (!OrderAddModel::insertOrderTrackRow($update_tracknumber)) { self::$errCode = "003"; self::$errMsg = "更新订单跟踪号插入失败!"; BaseModel::rollback(); return false; } } if ($update_note) { foreach ($update_note as $key => $value) { $notes = explode("###", $value); $where = " where content='{$notes[0]}' and omOrderId={$orderid}"; $set = "set content='{$notes[1]}',userId={$_SESSION['sysUserId']},createdTime=" . time(); $msg = OmAvailableModel::updateTNameRow("om_order_notes", $set, $where); if (!$msg) { self::$errCode = "004"; self::$errMsg = "更新订单备注失败!"; BaseModel::rollback(); return false; } } } if ($add_note) { foreach ($add_note as $key => $value) { $set = "set omOrderId={$orderid},content='{$value}',userId={$_SESSION['sysUserId']},createdTime=" . time(); $msg = OmAvailableModel::insertRow("om_order_notes", $set); if (!$msg) { self::$errCode = "005"; self::$errMsg = "插入订单备注失败!"; BaseModel::rollback(); return false; } } } self::$errCode = "200"; self::$errMsg = "整个订单信息更新成功!"; BaseModel::commit(); BaseModel::autoCommit(); } }
<?php require "/data/web/wh.valsun.cn/framework.php"; Core::getInstance(); $onhand = OmAvailableModel::getTNameList("wh_sku_location", "*", "where arrivalInventory>0"); foreach ($onhand as $on) { $total = 0; $onhand1 = OmAvailableModel::getTNameList("pc_goods", "*", "where sku='{$on['sku']}'"); $onhand2 = OmAvailableModel::getTNameList("wh_product_position_relation", "*", "where pId={$onhand1[0]['id']} and is_delete=0"); foreach ($onhand2 as $re) { $total += $re['nums']; } $update = OmAvailableModel::updateTNameRow("wh_sku_location", "set actualStock={$total}", "where sku='{$on['sku']}'"); echo $on['sku']; /* exit; print_r($total);exit; $fahuo2 = OmAvailableModel::getTNameList("wh_shipping_order as a inner join wh_shipping_order_relation as b on a.id=b.shipOrderId","a.id,b.originOrderId","where a.orderStatus=900 and b.originOrderId={$f['originOrderId']}"); if(!empty($fahuo2)){ print_r($fahuo2);echo"<br>"; foreach($fahuo2 as $ttt){ $fp = fopen('repeat.txt', 'a+'); $str = $ttt['id']; $str = "$str \n"; fwrite($fp, $str); } } */ } exit;
function act_deleteIoStoreById() { $id = intval($_GET['id']); if ($id <= 0) { self::$errCode = '101'; self::$errMsg = '无效记录,删除失败'; return false; } $tName = 'pc_products_iostore'; $select = 'iostoreTypeId'; $where = "WHERE id={$id} and is_delete=0"; $iostoreList = OmAvailableModel::getTNameList($tName, $select, $where); $iostoreTypeId = $iostoreList[0]['iostoreTypeId']; if (empty($iostoreTypeId)) { echo '错误单号!'; exit; } $mod = 'products'; $act = 'getOutStoreList'; if ($iostoreTypeId == 2) { $act = 'getInStoreList'; } try { BaseModel::begin(); $tName = 'pc_products_iostore'; $set = "SET is_delete=1"; $where = "WHERE id={$id}"; OmAvailableModel::updateTNameRow($tName, $set, $where); $tName = 'pc_products_iostore_detail'; $set = "SET is_delete=1"; $where = "WHERE iostoreId={$id}"; OmAvailableModel::updateTNameRow($tName, $set, $where); BaseModel::commit(); BaseModel::autoCommit(); $status = "删除成功"; header("Location:index.php?mod={$mod}&act={$act}&status={$status}"); } catch (Exception $e) { BaseModel::rollback(); BaseModel::autoCommit(); $status = $e->getMessage(); header("Location:index.php?mod={$mod}&act={$act}&status={$status}"); } }
function act_removeRollback() { $userId = $_SESSION['userId']; $time = time(); $shipOrderId = $_POST['order']; $sku = $_POST['sku']; $pName = $_POST['pname']; $scan_record = OmAvailableModel::getTNameList("wh_order_picking_records", "*", "where shipOrderId='{$shipOrderId}' and sku='{$sku}' and pName='{$pName}' and is_delete=0 "); if (empty($scan_record)) { self::$errCode = "401"; self::$errMsg = "配货单号 {$shipOrderId} 其中料号 {$sku} 在仓位 {$pName} 的配货记录不存在!"; return false; } else { OmAvailableModel::begin(); $amount = $scan_record[0]['amount']; //配货数量 $sql = "update ebay_order_scan_record set is_show = 1,canceltime='{$mctime}' where ebay_id = '{$ebay_id}' and sku = '{$ebay_sku}' and is_show = 0 "; $update_record = OmAvailableModel::updateTNameRow("wh_order_picking_records", "set cancelUserId='{$userId}',cancelTime='{$time}',is_delete=1", "where shipOrderId='{$shipOrderId}' and sku='{$sku}' and pName='{$pName}' and is_delete=0"); if (!$update_record) { self::$errCode = "402"; self::$errMsg = "配货单删除配货记录失败"; return false; } $sku_info = OmAvailableModel::getTNameList("pc_goods", "id", "where sku='{$sku}' and is_delete=0"); $position_info = OmAvailableModel::getTNameList("wh_position_distribution", "id", "where pName='{$pName}' and storeId=1"); if (!$position_info || !$sku_info) { self::$errCode = "403"; self::$errMsg = "配货单删除配货记录失败,找不到对应仓位id或者skuid"; OmAvailableModel::rollback(); return false; } $update_product_position = OmAvailableModel::updateTNameRow("wh_product_position_relation", "set nums=nums+'{$amount}'", "where pId={$sku_info[0]['id']} and positionId={$position_info[0]['id']}"); if (!$update_product_position) { self::$errCode = "404"; self::$errMsg = "配货单删除配货记录失败,更新仓位数量出错"; OmAvailableModel::rollback(); return false; } $update_sku_location = OmAvailableModel::updateTNameRow("wh_sku_location", "set actualStock=actualStock+'{$amount}'", "where sku='{$sku}' and storeId=1"); if (!$update_sku_location) { self::$errCode = "405"; self::$errMsg = "配货单删除配货记录失败,更新库存数量出错"; OmAvailableModel::rollback(); return false; } self::$errMsg = "配货单删除配货记录成功"; OmAvailableModel::commit(); return false; } }
function act_copyPPV() { //$pidNew = $_POST['pidNew']?post_check($_POST['pidNew']):'';//新建属性-类别 $finalIdArr = $_POST['finalIdStr']; //新建属性-类别4 $id = $_POST['id'] ? post_check($_POST['id']) : ''; //复制属性-类别 if (empty($finalIdArr) || empty($id)) { self::$errCode = 101; self::$errMsg = '类别或属性不能为空'; return false; } $tmpArr = array(); if (!is_array($finalIdArr)) { $tmpArr[] = $finalIdArr; $finalIdArr = $tmpArr; } //if(!is_array($finalIdArr)){ // $finalIdArr[] = $finalIdArr; // } //print_r($finalIdArr); // exit; // $pidArr = explode(",",$pid);//复制属性分割后的id数组 // if(in_array(array_pop($pidArr),$finalIdArr)){ // self :: $errCode = 107; // self :: $errMsg = '类别相同不能复制'; // return false; // } $finalPathArr = array(); foreach ($finalIdArr as $cid) { $catePath = CategoryModel::getCategoryPathById($cid); if (empty($catePath)) { self::$errCode = 109; self::$errMsg = '类别有误'; return false; } $finalPathArr[] = $catePath; } //print_r($finalPathArr); // exit; $tName = 'pc_goods_category'; foreach ($finalPathArr as $value) { $where = "WHERE path like'%{$value}-%' and is_delete=0"; $count = OmAvailableModel::getTNameCount($tName, $where); if ($count) { self::$errCode = 105; self::$errMsg = '只能在最小分类进行复制'; return false; } } // $tName = 'pc_archive_property'; // $select = '*'; // $where = "WHERE categoryPath='$pid'"; // $pidPropertyList = OmAvailableModel::getTNameList($tName, $select, $where);//复制属性-类别的list // if(empty($pidPropertyList)){ // self :: $errCode = 102; // self :: $errMsg = '复制属性-类别不存在,请检查是否该类别下有属性存在'; // return false; // } $tName = 'pc_archive_property'; $select = '*'; $where = "WHERE id={$id}"; $pidPropertyList = OmAvailableModel::getTNameList($tName, $select, $where); try { $pidNewStr = ''; BaseModel::begin(); foreach ($pidPropertyList as $value) { foreach ($finalPathArr as $pidNew) { $pidNewStr .= CategoryModel::getCategoryNameByPath($pidNew) . ' '; $id = $value['id']; //复制属性-类别 id $propertyName = $value['propertyName']; //复制属性-类别 的属性名 $isRadio = $value['isRadio']; //复制属性-类别 的单/多选 $isRequired = $value['isRequired']; //是否必填 add by zqt 20140423 $tName = 'pc_archive_property'; $select = 'id'; $where = "WHERE categoryPath='{$pidNew}' and propertyName='{$propertyName}'"; //判断新建属性-类别中是否存在复制中的同名属性,如果存在,则替换 $pidNewPropertyList = OmAvailableModel::getTNameList($tName, $select, $where); $tName = 'pc_archive_property_value'; $ppId = $pidNewPropertyList[0]['id']; //if(!empty($ppId)){ // $where = "WHERE propertyId=$ppId"; // OmAvailableModel::deleteTNameRow($tName, $where);//删除旧的属性值 // } if (empty($pidNewPropertyList)) { //不存在复制类中的同名属性时,insert; $tName = 'pc_archive_property'; $set = "SET propertyName='{$propertyName}',categoryPath='{$pidNew}',isRadio='{$isRadio}',isRequired='{$isRequired}'"; $insertPPId = OmAvailableModel::addTNameRow($tName, $set); if (!$insertPPId) { throw new Exception('add pc_archive_property error'); } //下面对值进行复制 $tName = 'pc_archive_property_value'; $select = '*'; $where = "WHERE propertyId={$id}"; $pidPpvList = OmAvailableModel::getTNameList($tName, $select, $where); //复制属性对应的属性值 foreach ($pidPpvList as $tmpValue) { $propertyId = $insertPPId; //复制后产生的id $propertyValue = $tmpValue['propertyValue']; $propertyValueAlias = $tmpValue['propertyValueAlias']; $propertyValueShort = $tmpValue['propertyValueShort']; $where = "WHERE propertyValue='{$propertyValue}'"; $countPPV = OmAvailableModel::getTNameCount($tName, $where); //判断复制的属性值是否存在; $set = "SET propertyId={$propertyId},propertyValue='{$propertyValue}',propertyValueAlias='{$propertyValueAlias}',propertyValueShort='{$propertyValueShort}'"; $insertPpvId = OmAvailableModel::addTNameRow($tName, $set); } } else { //存在时,先update原先属性的isRadio,再将对应的属性值更换就行了,如果属性值存在,则更新,不存在则insert $tName = 'pc_archive_property'; $set = "SET isRadio='{$isRadio}',isRequired='{$isRequired}'"; $where = "WHERE propertyName='{$propertyName}' and categoryPath='{$pidNew}'"; OmAvailableModel::updateTNameRow($tName, $set, $where); //下面对值进行复制 $tName = 'pc_archive_property_value'; $select = '*'; $where = "WHERE propertyId={$id}"; $pidPpvList = OmAvailableModel::getTNameList($tName, $select, $where); //复制属性对应的属性值 foreach ($pidPpvList as $tmpValue) { //添加新属性值 $propertyId = $ppId; //复制后产生的id $propertyValue = $tmpValue['propertyValue']; $propertyValueAlias = $tmpValue['propertyValueAlias']; $propertyValueShort = $tmpValue['propertyValueShort']; //找出老的ppvId记录 $select = '*'; $where = "WHERE propertyId={$propertyId} and propertyValue='{$propertyValue}'"; $oldPPVList = OmAvailableModel::getTNameList($tName, $select, $where); if (!empty($oldPPVList)) { $ppvId = $oldPPVList[0]['id']; $set = "SET propertyValue='{$propertyValue}',propertyValueAlias='{$propertyValueAlias}',propertyValueShort='{$propertyValueShort}'"; $where = "WHERE id={$ppvId}"; OmAvailableModel::updateTNameRow($tName, $set, $where); } else { $set = "SET propertyId={$propertyId},propertyValue='{$propertyValue}',propertyValueAlias='{$propertyValueAlias}',propertyValueShort='{$propertyValueShort}'"; $insertPpvId = OmAvailableModel::addTNameRow($tName, $set); } } } } } //$pidStr = getAllCateNameByPath($pid); BaseModel::commit(); BaseModel::autoCommit(); self::$errCode = 200; self::$errMsg = "{$pidPropertyList[0]['propertyName']} 复制到 {$pidNewStr} 成功"; return true; } catch (Exception $e) { BaseModel::rollback(); BaseModel::autoCommit(); self::$errCode = 201; self::$errMsg = $e->getMessage(); return false; } }
function act_updateTNameRow() { $jsonArr = isset($_GET['jsonArr']) ? $_GET['jsonArr'] : ''; //传过来的base64编码的json字符串 if (empty($jsonArr)) { self::$errCode = 101; self::$errMsg = '参数数组为空'; return false; } $jsonArr = json_decode(base64_decode($jsonArr), true); //对base64及json解码 if (!is_array($jsonArr)) { self::$errCode = 103; self::$errMsg = '参数数组不是数组格式'; return false; } $tName = $jsonArr['tName']; //表名 $set = $jsonArr['set']; //set,用关键字SET $where = $jsonArr['where']; //where,要带上关键字WHERE if (empty($tName) || empty($set) || empty($where)) { self::$errCode = '300'; self::$errMsg = '必要参数不完整'; return false; } $affectRows = OmAvailableModel::updateTNameRow($tName, $set, $where); if ($affectRows !== FALSE) { self::$errCode = '200'; self::$errMsg = '成功'; return $affectRows; } else { self::$errCode = '404'; self::$errMsg = '数据库操作错误'; return false; } }
} else { $sort = 0; } $set = "SET spu='{$spu}',purchaseId='{$purchaseId}',createdTime='{$now}',sort='{$sort}',status=2"; if (!$countAutoCreSpu) { OmAvailableModel::addTNameRow($tName, $set); echo "{$spu} autoCreateSpu insert success\n"; } //添加SPU档案 $tName = 'pc_spu_archive'; $where = "WHERE spu='{$spu}'"; $countSpuArchive = OmAvailableModel::getTNameCount($tName, $where); if ($countSpuArchive) { echo "{$spu} spuArchive has exist!\n"; $set = "SET categoryPath='{$value['goods_category']}',purchaseId='{$pcGoodsArr['purchaseId']}'"; OmAvailableModel::updateTNameRow($tName, $set, $where); echo "{$spu} spuArchive update category and purchaseId success! {$value['goods_category']} {$pcGoodsArr['purchaseId']} \n"; //continue; } $dataSpuArchive = array(); $dataSpuArchive['spu'] = $spu; $dataSpuArchive['categoryPath'] = $value['goods_category']; $dataSpuArchive['spuName'] = $value['goods_name']; $dataSpuArchive['spuPurchasePrice'] = $value['goods_cost']; $dataSpuArchive['spuLowestPrice'] = $value['goods_cost']; $dataSpuArchive['spuCalWeight'] = $value['goods_weight']; $dataSpuArchive['isPacking'] = $value['ispacking'] == 0 ? 1 : 2; $dataSpuArchive['spuNote'] = $value['goods_note']; $dataSpuArchive['spuSort'] = $value['mainsku']; $dataSpuArchive['purchaseId'] = $purchaseId; $dataSpuArchive['spuCreatedTime'] = $now;
function act_allPass() { $userCnName = $_SESSION['userCnName']; $id_arr = $_POST['id']; $f_count = count($id_arr); $id = implode(',', $id_arr); $where = "where id in(" . $id . ") and auditStatus=0"; $record_list = InvRecordModel::getInvRecordList("*", $where); $s_count = count($record_list); if ($f_count != $s_count) { self::$errCode = "401"; self::$errMsg = "当前包含有不用审核的订单,请确认!"; return false; } OmAvailableModel::begin(); foreach ($record_list as $record) { $data = array(); $id = $record['id']; $data = array('auditStatus' => 1); $Inv_info = InvRecordModel::getInvRecordList("*", "where id='{$id}'"); $position_info = OmAvailableModel::getTNameList("wh_position_distribution", "id", "where pName='{$Inv_info[0]['location']}'"); $skuinfo = whShelfModel::selectSku(" where sku='{$Inv_info[0]['sku']}'"); $updatedata = InvRecordModel::update($data, "and id='{$id}'"); if (!$updatedata) { self::$errCode = "402"; self::$errMsg = "更新通过状态失败!"; return false; } $tName = 'wh_product_position_relation'; $set = "SET nums='{$Inv_info[0]['invNums']}'"; $where = "WHERE pId='{$skuinfo['id']}' AND positionId='{$position_info[0]['id']}' AND is_delete=0 AND storeId=1"; $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where); //库存变化 if ($affectRow === false) { self::$errCode = "403"; self::$errMsg = "更新具体仓位库存失败!"; OmAvailableModel::rollback(); return false; } $adjustNums = $Inv_info[0]['adjustNums']; if ($Inv_info[0]['invType'] == 2) { $adjustNums = "-" . $adjustNums; } $tName = 'wh_sku_location'; $set = "SET actualStock=actualStock+'{$adjustNums}'"; $where = "WHERE sku='{$Inv_info[0]['sku']}' AND storeId=1"; $affectRow = WhIoRecordsModel::updateTNameRow($tName, $set, $where); //库存变化 if ($affectRow === false) { self::$errCode = "404"; self::$errMsg = "更新总库存失败!"; OmAvailableModel::rollback(); return false; } /**** 插入出入库记录 *****/ if ($Inv_info[0]['invType'] == 2) { $ioType = 1; $ioTypeId = 11; $reason = '盘点出库'; } else { $ioType = 2; $ioTypeId = 10; $reason = '盘点入库'; } if ($adjustNums != 0) { $update_onhand = CommonModel::adjustInventory($Inv_info[0]['sku'], $adjustNums, $userCnName); if ($update_onhand == 0) { self::$errCode = 415; self::$errMsg = "更新旧erp库存失败"; OmAvailableModel::rollback(); return false; } $skuinfo = whShelfModel::selectSku(" where sku = '{$Inv_info[0]['sku']}'"); $paraArr = array('sku' => $Inv_info[0]['sku'], 'amount' => abs($adjustNums), 'positionId' => $position_info[0]['id'], 'purchaseId' => $skuinfo['purchaseId'], 'ioType' => $ioType, 'ioTypeId' => $ioTypeId, 'userId' => $_SESSION['userId'], 'reason' => $reason); $record = CommonModel::addIoRecores($paraArr); //出库记录 if (!$record) { OmAvailableModel::rollback(); return false; } } //更新申请盘点表 $waitInf = WaitInventoryModel::updateInv($Inv_info[0]['sku'], $_SESSION['userId']); if (!$waitInf) { self::$errCode = 414; self::$errMsg = "跟新申请盘点表失败!"; TransactionBaseModel::rollback(); return false; } } OmAvailableModel::commit(); return true; }
function updateCheckCostModify($sku, $checkCost, $isTranDL = true) { $tName = 'pc_goods'; $set = "set checkCost='{$checkCost}'"; $where = "WHERE sku='{$sku}'"; OmAvailableModel::updateTNameRow($tName, $set, $where); error_log(date('Y-m-d_H:i') . "—— {$sku} 更新成功为 {$checkCost} \r\n", 3, WEB_PATH . "log/skuCheckCostModify.txt"); //interFaceForCNDLToMH($sku, 2); }