/**
  *功能:我自己运行的接口,批量更新数据,根据需求批量更新销售是陈智兴的虚拟料号,将其销售人员改为对应真实SPU的销售人员
  * */
 public function act_updateBatchForSalers()
 {
     $tName = 'pc_spu_saler_combine';
     $select = 'spu';
     $where = "WHERE is_delete=0 and platformId=2 and isAgree=2 and salerId=60";
     $combineSpuList = OmAvailableModel::getTNameList($tName, $select, $where);
     foreach ($combineSpuList as $value) {
         $combineSpu = $value['spu'];
         $tName = 'pc_goods_combine';
         $select = 'combineSku';
         $where = "WHERE is_delete=0 and combineSpu='{$combineSpu}'";
         $combineSkuList = OmAvailableModel::getTNameList($tName, $select, $where);
         if (!empty($combineSkuList)) {
             $tName = 'pc_sku_combine_relation';
             $select = 'sku';
             $where = "WHERE combineSku='{$combineSkuList[0]['combineSku']}'";
             $skuList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($skuList)) {
                 $tName = 'pc_goods';
                 $select = 'spu';
                 $where = "WHERE is_delete=0 and sku='{$skuList[0]['sku']}'";
                 $spuList = OmAvailableModel::getTNameList($tName, $select, $where);
                 if (!empty($spuList)) {
                     $tName = 'pc_spu_saler_single';
                     $select = 'salerId';
                     $where = "WHERE is_delete=0 and platformId=2 and isAgree=2 and spu='{$spuList[0]['spu']}'";
                     $singleSpuSalerIdList = OmAvailableModel::getTNameList($tName, $select, $where);
                     if (!empty($singleSpuSalerIdList)) {
                         $salerId = $singleSpuSalerIdList[0]['salerId'];
                         $saler = getPersonNameById($salerId);
                         $tName = 'pc_spu_saler_combine';
                         $where = "WHERE is_delete=0 and spu='{$combineSpu}'";
                         $dataArr = array();
                         $dataArr['salerId'] = $salerId;
                         OmAvailableModel::updateTNameRow2arr($tName, $dataArr, $where);
                         echo "{$combineSpu} 的原销售是 陈智兴,真实销售是 {$saler} <br />";
                     } else {
                         echo "{$combineSpu} 的原销售是 陈智兴,真实销售为空 <br />";
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function view_productsBack()
 {
     $sku = $_GET['sku'] ? $_GET['sku'] : '';
     $id = $_GET['id'] ? $_GET['id'] : '';
     $userId = $_SESSION['userId'];
     $now = time();
     if (intval($userId) <= 0) {
         $status = "未登录";
         header("Location:index.php?mod=products&act=getProductsTakeList&status={$status}&sku={$sku}");
         exit;
     }
     if (empty($id)) {
         $status = "id为空";
         header("Location:index.php?mod=products&act=getProductsTakeList&status={$status}&sku={$sku}");
         exit;
     }
     $idArr = array_filter(explode(',', $id));
     foreach ($idArr as $value) {
         if (intval($value) <= 0) {
             $status = "含有非法id";
             header("Location:index.php?mod=products&act=getProductsTakeList&status={$status}&sku={$sku}");
             exit;
         }
     }
     $newIdArr = implode(',', $idArr);
     $tName = 'pc_products';
     $set = "SET productsStatus=1";
     $where = "WHERE id in({$newIdArr})";
     OmAvailableModel::updateTNameRow($tName, $set, $where);
     $takeSpuArr = array();
     //同步数据到ERP
     $tName = 'pc_products';
     $select = 'sku';
     $where = "WHERE id in({$newIdArr})";
     $skuList = OmAvailableModel::getTNameList($tName, $select, $where);
     foreach ($skuList as $value) {
         $takeInfoArr = array();
         $takeInfoArr['sku'] = $value['sku'];
         $tName = 'pc_goods';
         $select = 'spu';
         $where = "WHERE is_delete=0 AND sku='{$value['sku']}'";
         $takeSpuList = OmAvailableModel::getTNameList($tName, $select, $where);
         if (!empty($takeSpuList)) {
             $takeSpuArr[] = $takeSpuList[0]['spu'];
         }
         $res = OmAvailableModel::newData2ErpInterfOpen('pc.erp.updateEbay_order_productForBack', $takeInfoArr, 'gw88');
     }
     $takeSpuArr = array_unique($takeSpuArr);
     foreach ($takeSpuArr as $value) {
         $tName = 'pc_spu_web_maker';
         $where = "WHERE is_delete=0 AND spu='{$value}' order by id desc limit 1";
         $dataArr = array();
         $dataArr['isTake'] = 0;
         OmAvailableModel::updateTNameRow2arr($tName, $dataArr, $where);
     }
     $status = "退还料号成功";
     header("Location:index.php?mod=products&act=getProductsComfirmList&status={$status}&sku={$sku}");
 }
Beispiel #3
0
 public function view_updateIsNewBatchExcelImportOn()
 {
     $useId = $_SESSION['userId'];
     $personName = getPersonNameById($useId);
     if (empty($personName)) {
         $status = "<font color=red>系统找不到登录人信息!</font><br/>";
         echo $status;
         exit;
     }
     if (isset($_POST['submit']) && $_POST['submit'] != '') {
         $uploadfile = 'updateIsNewBatchExcelImport_' . date("Y") . date("m") . date("d") . date("H") . date('i') . date('s') . '_' . $personName . ".xls";
         if (move_uploaded_file($_FILES['upfile']['tmp_name'], 'upload/' . $uploadfile)) {
             echo "<font color=BLUE>文件上传成功!</font><br>";
         } else {
             echo "<font color=red> 文件上传失败!</font>";
             exit;
         }
         $fileName = 'upload/' . $uploadfile;
         $filePath = $fileName;
         $PHPExcel = new PHPExcel();
         $PHPReader = new PHPExcel_Reader_Excel2007();
         if (!$PHPReader->canRead($filePath)) {
             $PHPReader = new PHPExcel_Reader_Excel5();
             if (!$PHPReader->canRead($filePath)) {
                 echo 'no Excel';
                 return;
             }
         }
         $PHPExcel = $PHPReader->load($filePath);
         $currentSheet = $PHPExcel->getSheet(0);
         $highestRow = $currentSheet->getHighestRow();
         //表格中的最大行数
         //var_dump($highestRow);exit;
         if ($highestRow > 500) {
             echo "表格不能超过500行,请重新整理表格导入,谢谢!";
             exit;
         }
         $status = '';
         $flag = true;
         //标识检测结果
         for ($i = 2; $i <= $highestRow; $i++) {
             //先检查导入表格的正确性
             $spu = trim($currentSheet->getCell('A' . $i)->getValue());
             //spu
             $spu = preg_replace("/(\\s|\\&nbsp\\;| | )/", "", $spu);
             $spu = strpos($spu, '_') === false ? str_pad($spu, 3, '0', STR_PAD_LEFT) : $spu;
             if (empty($spu)) {
                 $status .= "第 {$i} 行,SPU为空 <br/>";
                 $flag = false;
                 continue;
             }
             $tName = 'pc_products';
             $where = "WHERE is_delete=0 and productsStatus=2 and spu='{$spu}'";
             $spuCount = OmAvailableModel::getTNameCount($tName, $where);
             if (!$spuCount) {
                 $status .= "第 {$i} 行,{$spu} 不在领取料号状态 <br/>";
                 $flag = false;
                 continue;
             }
         }
         if (!$flag) {
             //验证不通过
             echo "<font color=red>{$status}</font>";
             exit;
         } else {
             $status = '';
             for ($i = 2; $i <= $highestRow; $i++) {
                 //先检查导入表格的正确性
                 $spu = trim($currentSheet->getCell('A' . $i)->getValue());
                 //spu
                 $spu = preg_replace("/(\\s|\\&nbsp\\;| | )/", "", $spu);
                 $spu = strpos($spu, '_') === false ? str_pad($spu, 3, '0', STR_PAD_LEFT) : $spu;
                 $tName = 'pc_products';
                 $where = "WHERE is_delete=0 and productsStatus=2 and spu='{$spu}'";
                 $dataArr = array();
                 $dataArr['productsStatus'] = 3;
                 $dataArr['productsCompleteTime'] = time();
                 OmAvailableModel::updateTNameRow2arr($tName, $dataArr, $where);
                 $_POST['spu'] = $spu;
                 $_POST['isNew'] = 0;
                 $goodsAct = new GoodsAct();
                 $goodsAct->act_updateIsNewBatch();
                 $status .= "第 {$i} 行,{$spu} 更新成功 <br/>";
             }
             echo "<font color=green>{$status}</font>";
             exit;
         }
     }
 }
Beispiel #4
0
 public function view_updateCombineOn()
 {
     $id = $_POST['id'] ? post_check(trim($_POST['id'])) : '';
     $combineSpu = $_POST['combineSpu'] ? post_check(trim($_POST['combineSpu'])) : '';
     $combineSku = $_POST['combineSku'] ? post_check(trim($_POST['combineSku'])) : '';
     $combineLength = $_POST['combineLength'] ? post_check(trim($_POST['combineLength'])) : '';
     $combineWidth = $_POST['combineWidth'] ? post_check(trim($_POST['combineWidth'])) : '';
     $combineHeight = $_POST['combineHeight'] ? post_check(trim($_POST['combineHeight'])) : '';
     $combineNote = $_POST['combineNote'] ? post_check(trim($_POST['combineNote'])) : '';
     $skuArr = $_POST['sku'];
     $countArr = $_POST['count'];
     if (empty($combineSpu)) {
         $status = "combineSpu为空";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     }
     if (!empty($combineLength)) {
         if (!is_numeric($combineLength) || $combineLength < 0) {
             $status = "长度必须为数字";
             echo '<script language="javascript">
                     alert("' . $status . '");
                     history.go(-1);
                   </script>';
             exit;
         }
     }
     if (!empty($combineWidth)) {
         if (!is_numeric($combineWidth) || $combineWidth < 0) {
             $status = "宽度必须为数字";
             echo '<script language="javascript">
                     alert("' . $status . '");
                     history.go(-1);
                   </script>';
             exit;
         }
     }
     if (!empty($combineHeight)) {
         if (!is_numeric($combineHeight) || $combineHeight < 0) {
             $status = "高度必须为数字";
             echo '<script language="javascript">
                     alert("' . $status . '");
                     history.go(-1);
                   </script>';
             exit;
         }
     }
     //检查spu是否非法
     if (intval($id) == 0) {
         $status = "非法id";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     }
     if (empty($combineSku)) {
         $status = "combineSku为空";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     }
     if (!preg_match("/^{$combineSpu}(_[A-Z0-9]+)*\$/", $combineSku)) {
         $status = "combineSku为空";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     }
     $tName = 'pc_goods_combine';
     $where = "WHERE is_delete=0 AND combineSku='{$combineSku}' AND id<>{$id}";
     //检测新sku是否已经存在
     $countNewSku = OmAvailableModel::getTNameCount($tName, $where);
     if ($countNewSku) {
         $status = "料号 {$combineSku} 已经存在";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     }
     if (empty($skuArr[0]) || empty($countArr[0])) {
         $status = "至少要包含一条真实料号对应记录";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     }
     $tName = 'pc_goods_combine';
     $select = 'combineSku';
     $where = "WHERE id={$id} and is_delete=0";
     $oldComSkuList = OmAvailableModel::getTNameList($tName, $select, $where);
     $oldComSku = $oldComSkuList[0]['combineSku'];
     if (empty($oldComSku)) {
         $status = "料号 {$oldComSku} 不存在";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     }
     $count = count($skuArr);
     $countFlip = count(array_flip($skuArr));
     if ($count != $countFlip) {
         $status = "存在重复的真实料号记录";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </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 = "真实料号 {$value} 不存在";
                 echo '<script language="javascript">
                         alert("' . $status . '");
                         history.go(-1);
                       </script>';
                 exit;
             }
         }
     }
     $dataCom = array();
     $dataCom['combineSku'] = $combineSku;
     $dataCom['combineLength'] = $combineLength;
     $dataCom['combineWidth'] = $combineWidth;
     $dataCom['combineHeight'] = $combineHeight;
     $dataCom['combineNote'] = $combineNote;
     try {
         BaseModel::begin();
         $tName = 'pc_goods_combine';
         $where = "WHERE id={$id}";
         $affectRow = OmAvailableModel::updateTNameRow2arr($tName, $dataCom, $where);
         if ($affectRow === false) {
             $status = "更新失败";
             throw new Exception('update combine error');
         }
         $dataRelation = array();
         $dataRelationMem = array();
         //用来更新mem中的detail数组
         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}'";
             $affectRow = OmAvailableModel::deleteTNameRow($tName, $where);
             if ($affectRow === false) {
                 throw new Exception('delete combine relation error');
             }
             foreach ($dataRelation as $value) {
                 $insertId = OmAvailableModel::addTNameRow2arr($tName, $value);
                 if ($insertId === false) {
                     throw new Exception('add combine relation error');
                 }
             }
         }
         //将新添加的sku添加到mem中
         $key = 'pc_goods_combine_' . $combineSku;
         $dataCom['combineSpu'] = $combineSpu;
         $dataCom['detail'] = $dataRelationMem;
         $value = $dataCom;
         setMemNewByKey('pc_goods_combine_' . $oldComSku, '');
         //旧的设为空
         setMemNewByKey($key, $value);
         //这里不保证能添加成功
         BaseModel::commit();
         BaseModel::autoCommit();
         //同步新数据到旧系统中
         $ebayProductsCombine = array();
         $ebayProductsCombine['id'] = $id;
         $ebayProductsCombine['old_goods_sn'] = $oldComSku;
         $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['ebay_user'] = '******';
         $ebayProductsCombine['createdtime'] = time();
         $ebayProductsCombine['truesku'] = implode(',', $truesku);
         $ret = OmAvailableModel::newData2ErpInterfOpen('pc.erp.updateCombine2', $ebayProductsCombine, 'gw88');
         $status = "{$combineSku} 更新成功";
         echo '<script language="javascript">
                 alert("' . $status . '");
                 history.go(-1);
               </script>';
         exit;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $status = "更新失败 " . $e->getMessage();
         echo '<script language="javascript">
                     alert("' . $status . '");
                     history.go(-1);
                     </script>';
     }
 }
Beispiel #5
0
 function act_confirmReceivingByMFG()
 {
     $ioStoreId = !empty($_POST['ioStoreId']) ? $_POST['ioStoreId'] : 0;
     $comfirmUserId = $_SESSION['userId'];
     $now = time();
     if (intval($ioStoreId) <= 0) {
         self::$errCode = '101';
         self::$errMsg = "id有误";
         return false;
     }
     if (intval($comfirmUserId) <= 0) {
         self::$errCode = '102';
         self::$errMsg = "登陆超时,请重试";
         return false;
     }
     $tName = 'pc_products_iostore';
     $select = '*';
     $where = "WHERE is_delete=0 AND isAudit=2 AND id='{$ioStoreId}'";
     $ioStoreList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($ioStoreList)) {
         self::$errCode = '103';
         self::$errMsg = "该单据不存在或者未审核通过";
         return false;
     }
     try {
         BaseModel::begin();
         //标记表头已经确认
         $dataIoStore = array();
         $dataIoStore['isComfirm'] = 2;
         //标记单据已经确认
         $dataIoStore['comfirmUserId'] = $comfirmUserId;
         $dataIoStore['comfirmTime'] = $now;
         OmAvailableModel::updateTNameRow2arr($tName, $dataIoStore, $where);
         //标记表体确认
         $tName = 'pc_products_iostore_detail';
         $dataIoStoreDetail = array();
         $dataIoStoreDetail['isComfirm'] = 2;
         $where = "WHERE iostoreId='{$ioStoreId}'";
         OmAvailableModel::updateTNameRow2arr($tName, $dataIoStoreDetail, $where);
         //如果是新品领料单,则产品部确认后,该单据下的sku才进入产品制作表
         if ($ioStoreList[0]['iostoreTypeId'] == 1 && $ioStoreList[0]['useTypeId'] == 1) {
             $select = 'sku';
             $skuList = OmAvailableModel::getTNameList($tName, $select, $where);
             foreach ($skuList as $value) {
                 $sku = $value['sku'];
                 $tName = 'pc_products';
                 $dataProducts = array();
                 $dataProducts['sku'] = $sku;
                 OmAvailableModel::addTNameRow2arr($tName, $dataProducts);
                 //将detail中的sku加入到产品制作表中
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         self::$errCode = '200';
         self::$errMsg = "确认收货成功";
         return true;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         self::$errCode = '404';
         self::$errMsg = $e->getMessage();
         return false;
     }
 }
Beispiel #6
0
 function act_updateSpuHsRelaById()
 {
     $id = intval($_POST['id']);
     if ($id <= 0) {
         self::$errCode = '101';
         self::$errMsg = '无效记录';
         return false;
     }
     $userId = $_SESSION['userId'];
     if ($id <= 0) {
         self::$errCode = '103';
         self::$errMsg = '登陆超时';
         return false;
     }
     $personName = getPersonNameById($userId);
     $tName = 'pc_spu_tax_hscode';
     $select = 'spu';
     $where = "WHERE id='{$id}'";
     $psthList = OmAvailableModel::getTNameList($tName, $select, $where);
     if (empty($psthList)) {
         self::$errCode = '102';
         self::$errMsg = "无记录";
         return false;
     }
     $dataTmpArr = array();
     $dataTmpArr['customsName'] = !empty($_POST['customsName']) ? $_POST['customsName'] : '';
     $dataTmpArr['materialCN'] = !empty($_POST['materialCN']) ? $_POST['materialCN'] : '';
     $dataTmpArr['customsNameEN'] = !empty($_POST['customsNameEN']) ? $_POST['customsNameEN'] : '';
     $dataTmpArr['materialEN'] = !empty($_POST['materialEN']) ? $_POST['materialEN'] : '';
     $dataTmpArr['hsCode'] = !empty($_POST['hsCode']) ? $_POST['hsCode'] : '';
     $dataTmpArr['exportRebateRate'] = !empty($_POST['exportRebateRate']) ? $_POST['exportRebateRate'] : '';
     $dataTmpArr['importMFNRates'] = !empty($_POST['importMFNRates']) ? $_POST['importMFNRates'] : '';
     $dataTmpArr['generalRate'] = !empty($_POST['generalRate']) ? $_POST['generalRate'] : '';
     $dataTmpArr['RegulatoryConditions'] = !empty($_POST['RegulatoryConditions']) ? $_POST['RegulatoryConditions'] : '';
     $dataTmpArr = array_filter($dataTmpArr);
     $jsonData = json_encode($dataTmpArr);
     if (!empty($dataTmpArr)) {
         OmAvailableModel::updateTNameRow2arr($tName, $dataTmpArr, $where);
         error_log(date('Y-m-d_H:i') . "——{$psthList[0]['spu']} 更新成功 BY {$personName}, data: {$jsonData} \r\n", 3, WEB_PATH . "log/spuHscodeTax.txt");
         self::$errCode = '200';
         self::$errMsg = "更新成功";
         return true;
     } else {
         self::$errCode = '200';
         self::$errMsg = "无数据提交";
         return true;
     }
 }
 public function act_updateSpecialTMTCOn()
 {
     $id = $_POST['id'] ? trim($_POST['id']) : 0;
     $specialTransportManagerName = $_POST['specialTransportManagerName'] ? trim($_POST['specialTransportManagerName']) : '';
     $isOn = $_POST['isOn'] ? trim($_POST['isOn']) : '';
     //$canOrNot = $_POST['canOrNot'] ? (trim($_POST['canOrNot'])) : '';
     $transportIdArr = !empty($_POST['transportId']) ? $_POST['transportId'] : array();
     //选中的transportId数组
     //print_r($transportIdArr);exit;
     $tName = 'pc_special_transport_manager';
     $where = "WHERE id='{$id}'";
     $pspIsExist = OmAvailableModel::getTNameCount($tName, $where);
     if (!$pspIsExist) {
         $status = "记录不存在,错误";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     if (empty($specialTransportManagerName)) {
         $status = "特殊运输方式名称为空";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     if (intval($isOn) <= 0) {
         $status = "是否启用有误";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     if (empty($transportIdArr)) {
         $status = "所选的运输方式为空,错误";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     $tName = 'pc_special_transport_manager';
     $where = "WHERE specialTransportManagerName='{$specialTransportManagerName}' AND id<>'{$id}'";
     $properNameIsExist = OmAvailableModel::getTNameCount($tName, $where);
     if ($properNameIsExist) {
         $status = "该特殊运输方式名称已经存在,请检查";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
     try {
         BaseModel::begin();
         $tName = 'pc_special_transport_manager';
         $dataTmpArr = array();
         $dataTmpArr['specialTransportManagerName'] = $specialTransportManagerName;
         $dataTmpArr['isOn'] = $isOn;
         $where = "WHERE id='{$id}'";
         OmAvailableModel::updateTNameRow2arr($tName, $dataTmpArr, $where);
         $tName = 'pc_special_stmnid_transportid';
         $select = '*';
         $where = "WHERE stmnId='{$id}'";
         $psptList = OmAvailableModel::getTNameList($tName, $select, $where);
         $psptIdArr = array();
         foreach ($psptList as $value) {
             $psptIdArr[] = $value['id'];
         }
         $psptIdStr = !empty($psptIdArr) ? implode(',', $psptIdArr) : 0;
         $tName = 'pc_special_stid_channel';
         $where = "WHERE stId in({$psptIdStr})";
         OmAvailableModel::deleteTNameRow($tName, $where);
         //删除渠道关系表的相关数据
         $tName = 'pc_special_stmnid_transportid';
         $where = "WHERE stmnId='{$id}'";
         OmAvailableModel::deleteTNameRow($tName, $where);
         //删除运输方式关系表的相关数据
         foreach ($transportIdArr as $transportId) {
             if (intval($transportId) > 0) {
                 $channelIdArr = !empty($_POST['tc' . $transportId]) ? $_POST['tc' . $transportId] : array();
                 //该transpordeId下的channel数组
                 $tName = 'pc_special_stmnid_transportid';
                 $dataTmpArr = array();
                 $dataTmpArr['stmnId'] = $id;
                 $dataTmpArr['transportId'] = $transportId;
                 $insertPTId = OmAvailableModel::addTNameRow2arr($tName, $dataTmpArr);
                 if (intval($insertPTId) <= 0) {
                     throw new Exception('insertPTId 错误');
                 }
                 foreach ($channelIdArr as $channelId) {
                     if (intval($channelId) > 0) {
                         $tName = 'pc_special_stid_channel';
                         $dataTmpArr = array();
                         $dataTmpArr['stId'] = $insertPTId;
                         $dataTmpArr['channelId'] = $channelId;
                         OmAvailableModel::addTNameRow2arr($tName, $dataTmpArr);
                     }
                 }
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         $status = "修改成功";
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $status = '失败,原因为:' . $e->getMessage();
         echo '<script language="javascript">
                     alert("' . $status . '");
                     </script>';
         exit;
     }
 }
Beispiel #8
0
 public function view_updateSpuPersonOn()
 {
     $spu = $_POST['spu'] ? post_check(trim($_POST['spu'])) : '';
     $isSingSpu = $_POST['isSingSpu'] ? post_check(trim($_POST['isSingSpu'])) : 0;
     $ebaySalerId = $_POST['ebaySalerId'] ? post_check(trim($_POST['ebaySalerId'])) : 0;
     $aliexpressSalerId = $_POST['aliexpressSalerId'] ? post_check(trim($_POST['aliexpressSalerId'])) : 0;
     $amazonSalerId = $_POST['amazonSalerId'] ? post_check(trim($_POST['amazonSalerId'])) : 0;
     $overseaSalerId = $_POST['overseaSalerId'] ? post_check(trim($_POST['overseaSalerId'])) : 0;
     $webMakerId = $_POST['webMakerId'] ? post_check(trim($_POST['webMakerId'])) : 0;
     if ($isSingSpu != 1 && $isSingSpu != 2) {
         $status = "基础数据 单/虚拟料号出错!";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     }
     if (intval($_SESSION['userId']) <= 0) {
         $status = "登陆超时,请重新登陆";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     }
     if (intval($ebaySalerId) <= 0 && intval($aliexpressSalerId) <= 0 && intval($amazonSalerId) <= 0 && !isAccessAll('autoCreateSpu', 'isCanUpdateWebMakerPower')) {
         $status = "ebay/aliexpress/amazon 平台中至少要存在一个销售人员记录才能提交";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     }
     try {
         BaseModel::begin();
         $status = '';
         if ($isSingSpu == 1) {
             $tName = 'pc_spu_saler_single';
         } else {
             $tName = 'pc_spu_saler_combine';
         }
         $select = 'isAgree,salerId';
         if (!empty($ebaySalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=1";
             //ebay平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $ebaySalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $ebaySalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $ebaySalerId;
                 $dataEbayArr['platformId'] = 1;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($aliexpressSalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=2";
             //ali平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $aliexpressSalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $aliexpressSalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $aliexpressSalerId;
                 $dataEbayArr['platformId'] = 2;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($amazonSalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=11";
             //amazon平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $amazonSalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $amazonSalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $amazonSalerId;
                 $dataEbayArr['platformId'] = 11;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($overseaSalerId)) {
             $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId=14";
             //amazon平台
             $ebaySpuSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (!empty($ebaySpuSalerList)) {
                 //更新时如果人员改动会更新是否接手状态,但是不会更新是否被销售同意/拒绝状态
                 if ($ebaySpuSalerList[0]['salerId'] != $overseaSalerId) {
                     $dataEbayArr = array();
                     $dataEbayArr['salerId'] = $overseaSalerId;
                     $dataEbayArr['isAgree'] = 1;
                     //add by zqt 20140421,如果换人了的话,则变为待定状态
                     $dataEbayArr['addTime'] = time();
                     OmAvailableModel::updateTNameRow2arr($tName, $dataEbayArr, $where);
                 }
             } else {
                 //插入新数据时,则默认销售同意/拒绝状态为待定
                 $dataEbayArr = array();
                 $dataEbayArr['spu'] = $spu;
                 $dataEbayArr['salerId'] = $overseaSalerId;
                 $dataEbayArr['platformId'] = 14;
                 $dataEbayArr['addTime'] = time();
                 $dataEbayArr['isAgree'] = 1;
                 OmAvailableModel::addTNameRow2arr($tName, $dataEbayArr);
             }
         }
         if (!empty($webMakerId)) {
             $tName = 'pc_spu_web_maker';
             $select = 'webMakerId,isAgree,isTake';
             $where = "WHERE is_delete=0 AND spu='{$spu}' order by id desc limit 1";
             $spuWebMakerList = OmAvailableModel::getTNameList($tName, $select, $where);
             if (empty($spuWebMakerList)) {
                 //不存在该SPU的指派记录
                 $dataWebMakerArr = array();
                 $dataWebMakerArr['spu'] = $spu;
                 $dataWebMakerArr['isSingSpu'] = $isSingSpu;
                 $dataWebMakerArr['webMakerId'] = $webMakerId;
                 $dataWebMakerArr['isAgree'] = 1;
                 //add by 20140513,待定状态
                 $dataWebMakerArr['addTime'] = time();
                 OmAvailableModel::addTNameRow2arr($tName, $dataWebMakerArr);
             } else {
                 //存在指派记录时
                 if ($spuWebMakerList[0]['webMakerId'] != $webMakerId) {
                     //提交的人和之前的不一致则修改/添加,否则不变
                     if ($spuWebMakerList[0]['isTake'] == 1) {
                         //如果是已经被工程师领取,则表示接手
                         $dataWebMakerArr = array();
                         $dataWebMakerArr['spu'] = $spu;
                         $dataWebMakerArr['isSingSpu'] = $isSingSpu;
                         $dataWebMakerArr['webMakerId'] = $webMakerId;
                         $dataWebMakerArr['addTime'] = time();
                         $dataWebMakerArr['isAgree'] = $spuWebMakerList[0]['isAgree'];
                         //add by 20140513,同意/拒绝状态不变
                         $dataWebMakerArr['isHandsOn'] = 1;
                         OmAvailableModel::addTNameRow2arr($tName, $dataWebMakerArr);
                     } else {
                         //如果未被领取,则只是修改记录
                         $dataWebMakerArr = array();
                         $dataWebMakerArr['webMakerId'] = $webMakerId;
                         $dataWebMakerArr['addTime'] = time();
                         $dataWebMakerArr['isAgree'] = 1;
                         //add by 20140513,未领取的话,重新变成待定状态
                         OmAvailableModel::updateTNameRow2arr($tName, $dataWebMakerArr, $where);
                     }
                 }
             }
         }
         BaseModel::commit();
         BaseModel::autoCommit();
         $status = "更新成功";
         echo '<script language="javascript">
                 alert("' . $status . '");
               </script>';
         exit;
     } catch (Exception $e) {
         BaseModel::rollback();
         BaseModel::autoCommit();
         $status = $e->getMessage();
         echo '<script language="javascript">
                 alert("' . '添加失败——' . $status . '");
               </script>';
         exit;
     }
 }
Beispiel #9
0
function addOrUpdateSalerInfo($platformId, $spu, $isSingSpu, $salerId)
{
    if ($isSingSpu == 1) {
        //单料号
        $tName = 'pc_spu_saler_single';
    } else {
        $tName = 'pc_spu_saler_combine';
    }
    $select = 'salerId';
    $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId='{$platformId}'";
    $oldSalerList = OmAvailableModel::getTNameList($tName, $select, $where);
    $dataArr = array();
    if (empty($oldSalerList)) {
        //如果记录不存在,则插入数据
        $dataArr['platformId'] = $platformId;
        $dataArr['spu'] = $spu;
        $dataArr['salerId'] = $salerId;
        $dataArr['addTime'] = time();
        OmAvailableModel::addTNameRow2arr($tName, $dataArr);
    } else {
        //有该平台及该SPU的销售人记录时
        if ($oldSalerList[0]['salerId'] != $salerId) {
            //如果销售人不同时,则修改
            $dataArr['salerId'] = $salerId;
            $dataArr['isHandsOn'] = 1;
            //更改接手状态
            $dataArr['addTime'] = time();
            //更新添加时间
            OmAvailableModel::updateTNameRow2arr($tName, $dataArr, $where);
        }
    }
}
            $tmpArr['sku'] = $sku;
            $tmpArr['isHasStock'] = $isHasStock;
            $tmpArr['whId'] = $whId;
            $tmpArr['isHasLocation'] = $isHasLocation;
            $tmpArr['location'] = $location;
            $tmpArr['storageTime'] = $storageTime;
            $tmpArr['updateTime'] = time();
            if (!$wlraleCount) {
                //如果不存在记录
                OmAvailableModel::addTNameRow2arr($tName, $tmpArr);
                echo "添加记录 成功 \n";
                echo "‘ {$sku} ’ ‘ {$isHasStock} ’ ‘ {$whId} ’ ‘ {$isHasLocation} ’ ‘ {$location} ’ ‘ {$storageTime} ’ \n";
            } else {
                //存在记录
                unset($tmpArr['sku'], $tmpArr['whId']);
                OmAvailableModel::updateTNameRow2arr($tName, $tmpArr, $where);
                echo "更新记录 成功 \n";
                echo "‘ {$sku} ’ ‘ {$isHasStock} ’ ‘ {$whId} ’ ‘ {$isHasLocation} ’ ‘ {$location} ’ ‘ {$storageTime} ’ \n";
            }
            BaseModel::commit();
            BaseModel::autoCommit();
        } catch (Exception $e) {
            //发生错误则进行下次循环
            BaseModel::rollback();
            BaseModel::autoCommit();
            echo "‘ {$sku} ’ 记录插入/更新失败,数据回滚,进入下次循环\n";
            continue;
        }
    }
    $page++;
} while ($totalPage >= $page);