Example #1
0
 public function view_addSku()
 {
     $spu = $_GET['spu'] ? post_check(trim($_GET['spu'])) : '';
     //检查spu,pid是否非法
     if (empty($spu)) {
         $status = "非法spu";
         header("Location:index.php?mod=autoCreateSpu&act=getAutoCreateSpuList&status={$status}&spu={$spu}");
         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=getAutoCreateSpuList&status={$status}");
         exit;
     }
     $isSingSpu = $autoSpuList[0]['isSingSpu'];
     //单/虚拟料号
     if ($isSingSpu == 1) {
         //单料号
         $tName = 'pc_spu_archive';
         $select = '*';
         $where = "WHERE spu='{$spu}' and is_delete=0";
         $spuArchiveList = OmAvailableModel::getTNameList($tName, $select, $where);
         if (empty($spuArchiveList)) {
             $status = "未找到 {$spu} 的产品档案信息";
             header("Location:index.php?mod=autoCreateSpu&act=getAutoCreateSpuList&status={$status}");
             exit;
         }
         $tName = 'pc_archive_spu_property_value_relation';
         $select = '*';
         $where = "WHERE spu='{$spu}'";
         $PPV = OmAvailableModel::getTNameList($tName, $select, $where);
         $tName = 'pc_archive_spu_input_value_relation';
         $INV = OmAvailableModel::getTNameList($tName, $select, $where);
         $tName = 'pc_archive_spu_link';
         $Link = OmAvailableModel::getTNameList($tName, $select, $where);
         $navlist = array(array('url' => 'index.php?mod=autoCreateSpu&act=getAutoCreatePrefixList', 'title' => 'SPU管理'), array('url' => 'index.php?mod=autoCreateSpu&act=getAutoCreateSpuList', 'title' => '生成SPU列表管理'), array('url' => "index.php?mod=autoCreateSpu&act=addSku&spu={$spu}", 'title' => "添加单料号_{$spu}"));
         $this->smarty->assign('navlist', $navlist);
         $this->smarty->assign('onevar', 2);
         $this->smarty->assign('twovar', 22);
         $this->smarty->assign('title', '添加单料号');
         $this->smarty->assign('spu', $spuArchiveList[0]['spu']);
         $this->smarty->assign('pid', $spuArchiveList[0]['categoryPath']);
         $this->smarty->assign('spuName', $spuArchiveList[0]['spuName']);
         $this->smarty->assign('spuPurchasePrice', $spuArchiveList[0]['spuPurchasePrice']);
         $this->smarty->assign('purchaseId', $spuArchiveList[0]['purchaseId']);
         $this->smarty->assign('spuLowestPrice', $spuArchiveList[0]['spuLowestPrice']);
         $this->smarty->assign('referMonthSales', $spuArchiveList[0]['referMonthSales']);
         $this->smarty->assign('lowestUrl', $spuArchiveList[0]['lowestUrl']);
         $this->smarty->assign('bidUrl', $spuArchiveList[0]['bidUrl']);
         $this->smarty->assign('spuLength', $spuArchiveList[0]['spuLength']);
         $this->smarty->assign('spuWidth', $spuArchiveList[0]['spuWidth']);
         $this->smarty->assign('spuCalWeight', $spuArchiveList[0]['spuCalWeight']);
         $this->smarty->assign('spuHeight', $spuArchiveList[0]['spuHeight']);
         $this->smarty->assign('isPacking', $spuArchiveList[0]['isPacking']);
         $this->smarty->assign('pmId', $spuArchiveList[0]['pmId']);
         $this->smarty->assign('spuNote', $spuArchiveList[0]['spuNote']);
         $this->smarty->assign('spuStatus', $spuArchiveList[0]['spuStatus']);
         $this->smarty->assign('auditStatus', $spuArchiveList[0]['auditStatus']);
         $pathImplodeStr = getAllPathBypid($spuArchiveList[0]['categoryPath']);
         $this->smarty->assign('pathImplodeStr', $pathImplodeStr);
         $isColor = isExistForSpuPPV($spu, '颜色');
         //检测该spu是否关联了颜色属性值
         $isSize = isExistForSpuPPV($spu, '尺码');
         $isSpuExist = isSpuExist($spu);
         $this->smarty->assign('isColor', $isColor);
         $this->smarty->assign('isSize', $isSize);
         $this->smarty->assign('isSpuExist', $isSpuExist);
         $isRelatedColor = isRelatedWithPidAndPP($spuArchiveList[0]['categoryPath'], '颜色');
         //检测该类是否关联了颜色属性
         $isRelatedSize = isRelatedWithPidAndPP($spuArchiveList[0]['categoryPath'], '尺码');
         $this->smarty->assign('isRelatedColor', $isRelatedColor);
         $this->smarty->assign('isRelatedSize', $isRelatedSize);
         $this->smarty->assign('PPV', $PPV);
         $this->smarty->assign('INV', $INV);
         $this->smarty->assign('Link', $Link);
         $this->smarty->assign('onevar', 2);
         $this->smarty->assign('twovar', 22);
         $this->smarty->display("addSkuSing.htm");
     } else {
         //虚拟料号
         $amount = $_GET['amount'] ? post_check(trim($_GET['amount'])) : 0;
         $amount = intval($amount);
         if ($amount <= 0 || $amount > 100) {
             $status = "数量必须在1-100之间";
             header("Location:index.php?mod=autoCreateSpu&act=getAutoCreateSpuList&status={$status}");
             exit;
         }
         $navlist = array(array('url' => 'index.php?mod=autoCreateSpu&act=getAutoCreatePrefixList', 'title' => 'SPU管理'), array('url' => 'index.php?mod=autoCreateSpu&act=getAutoCreateSpuList', 'title' => '生成SPU列表管理'), array('url' => "index.php?mod=autoCreateSpu&act=addSku&spu={$spu}", 'title' => "添加虚拟料号_{$spu}"));
         $this->smarty->assign('navlist', $navlist);
         $this->smarty->assign('onevar', 2);
         $this->smarty->assign('twovar', 22);
         $this->smarty->assign('title', '添加虚拟料号');
         $this->smarty->assign('combineSpu', $spu);
         $this->smarty->assign('amount', $amount);
         $this->smarty->display("addCombine.htm");
     }
 }
Example #2
0
 /**
  *功能:通过Sku信息获取其对应的海关编码及材质信息
  *@para $skuArr sku(一维)的json数组,形为json_encode(array('sku1','sku2',....)),注意,单个sku也必须封装成数组形式,非数组形式的参数均会返回报错信息
  *@return
  * */
 public function act_getHsCodeAndMaterialBySkuArr()
 {
     $skuArr = json_decode($_GET['skuArr'], true);
     if (!is_array($skuArr)) {
         self::$errCode = "101";
         self::$errMsg = "参数必须是Json数组";
         return;
     }
     if (empty($skuArr)) {
         self::$errCode = "102";
         self::$errMsg = "参数数组为空";
         return;
     }
     $returnArr = array();
     //要返回的数组
     $hsCodeArr = array();
     //海关编码数组
     $materialArr = array();
     //材质数组
     foreach ($skuArr as $value) {
         $sku = post_check(trim($value));
         //参数过滤
         if (empty($sku)) {
             //如果为空则跳过
             continue;
         }
         //下面是获取sku对应的海关编码数组
         $tName = 'pc_sku_hscode';
         $select = 'hsCode';
         $where = "WHERE isUsable=1 AND sku='{$sku}' order by id desc";
         $skuHsCodeList = OmAvailableModel::getTNameList($tName, $select, $where);
         $tmpHsCodeArr = array();
         foreach ($skuHsCodeList as $skuHsCode) {
             $tmpHsCodeArr[] = $skuHsCode['hsCode'];
         }
         $hsCodeArr[$value] = $tmpHsCodeArr;
         //下面是获取sku对应的材质数组
         $tName = 'pc_goods';
         $select = 'spu';
         $where = "WHERE is_delete=0 AND sku='{$sku}'";
         $spuList = OmAvailableModel::getTNameList($tName, $select, $where);
         $spu = $spuList[0]['spu'];
         if (!empty($spu)) {
             $ppvIdArr = isExistForSpuPPV($spu, '材质');
             //echo '$ppvIdArr ==== ';
             //                print_r($ppvIdArr);
             //                exit;
             if (!empty($ppvIdArr)) {
                 $tmpValAliArr = array();
                 foreach ($ppvIdArr as $valuePpv) {
                     $ppvId = intval($valuePpv['propertyValueId']);
                     if ($ppvId > 0) {
                         $tName = 'pc_archive_property_value';
                         $select = 'propertyValue,propertyValueAlias';
                         //属性值名称,和属性值别名(英文名)
                         $where = "WHERE id={$ppvId}";
                         $ppvValAlaArr = OmAvailableModel::getTNameList($tName, $select, $where);
                         if (!empty($ppvValAlaArr)) {
                             $tmpValAliArr[] = $ppvValAlaArr;
                         }
                     }
                 }
                 //print_r($tmpValAliArr);
                 //                    exit;
                 $materialArr[$value] = $tmpValAliArr;
             }
         }
     }
     //
     $returnArr['hsCode'] = $hsCodeArr;
     $returnArr['material'] = $materialArr;
     self::$errCode = "200";
     self::$errMsg = "success";
     return $returnArr;
 }
Example #3
0
 public function view_spuHscodeTaxExcelOutPutOn()
 {
     $type = intval($_POST['type']);
     $isOrNot = intval($_POST['isOrNot']);
     if ($type <= 0 || $isOrNot <= 0) {
         //修改为全表导出
         $fileName = "spuAllExcel_" . date('Y-m-d_H:i') . ".xls";
         $excel = new ExportDataExcel('browser', $fileName);
         $excel->initialize();
         $tableHeader = array('SPU', '描述', '类别', '采购材质', '供应商链接', '中文名称', '中文材质', '英文名称', '英文材质', '海关编码', '出口退税率', '进口最惠国税率', '一般税率', '监管条件');
         $excel->addRow($tableHeader);
         $tName = 'pc_goods';
         $select = 'spu,goodsName,goodsCategory';
         $where = "WHERE is_delete=0 group by spu";
         $spuList = OmAvailableModel::getTNameList($tName, $select, $where);
         foreach ($spuList as $value) {
             $tName = 'pc_spu_tax_hscode';
             $select = '*';
             $where = "WHERE spu='{$value['spu']}'";
             $spuHscodeList = OmAvailableModel::getTNameList($tName, $select, $where);
             $purchaseMaterialCNList = isExistForSpuPPV($value['spu'], '材质');
             //采购填写的材质
             $tmpArr = array();
             foreach ($purchaseMaterialCNList as $v) {
                 $tName = 'pc_archive_property_value';
                 $select = 'propertyValue';
                 $where = "WHERE id='{$v['propertyValueId']}'";
                 $tmpArr2 = OmAvailableModel::getTNameList($tName, $select, $where);
                 $tmpArr[] = $tmpArr2[0]['propertyValue'];
             }
             $tName = 'pc_archive_spu_link';
             $select = 'linkUrl';
             $where = "WHERE spu='{$value['spu']}' and linkNote like'供应商%' order by id desc limit 1";
             $paslList = OmAvailableModel::getTNameList($tName, $select, $where);
             $tbodyArray = array();
             $tbodyArray[] = $value['spu'];
             $tbodyArray[] = $value['goodsName'];
             $tbodyArray[] = getAllCateNameByPath($value['goodsCategory']);
             $tbodyArray[] = implode(',', $tmpArr);
             //采购材质
             $tbodyArray[] = $paslList[0]['linkUrl'];
             //供应商链接
             $tbodyArray[] = $spuHscodeList[0]['customsName'];
             $tbodyArray[] = $spuHscodeList[0]['materialCN'];
             $tbodyArray[] = $spuHscodeList[0]['customsNameEN'];
             $tbodyArray[] = $spuHscodeList[0]['materialEN'];
             $tbodyArray[] = $spuHscodeList[0]['hsCode'];
             $tbodyArray[] = $spuHscodeList[0]['exportRebateRate'];
             $tbodyArray[] = $spuHscodeList[0]['importMFNRates'];
             $tbodyArray[] = $spuHscodeList[0]['generalRate'];
             $tbodyArray[] = $spuHscodeList[0]['RegulatoryConditions'];
             $excel->addRow($tbodyArray);
         }
         $excel->finalize();
         exit;
     }
     try {
         if ($isOrNot == 1) {
             //导出有记录的SPU
             $fileName = "spuHscodeTaxExcel_" . date('Y-m-d_H:i') . ".xls";
             $excel = new ExportDataExcel('browser', $fileName);
             $excel->initialize();
             $tableHeader = array('SPU', '中文名称', '中文材质', '英文名称', '英文材质', '海关编码', '出口退税率', '进口最惠国税率', '一般税率', '监管条件');
             $excel->addRow($tableHeader);
             $tName = 'pc_spu_tax_hscode';
             $select = '*';
             if ($type == 1) {
                 //1.中文品名/材质 2.海关编码 3.英文品名/材质
                 $where = "WHERE customsName<>'' and materialCN<>''";
             } elseif ($type == 2) {
                 $where = "WHERE hsCode<>''";
             } elseif ($type == 3) {
                 $where = "WHERE customsNameEN<>'' and materialEN<>''";
             } elseif ($type == 4) {
                 $where = "WHERE customsName<>''";
             }
             $spuHsInfoList = OmAvailableModel::getTNameList($tName, $select, $where);
             foreach ($spuHsInfoList as $value) {
                 $tbodyArray = array();
                 $tbodyArray[] = $value['spu'];
                 $tbodyArray[] = $value['customsName'];
                 $tbodyArray[] = $value['materialCN'];
                 $tbodyArray[] = $value['customsNameEN'];
                 $tbodyArray[] = $value['materialEN'];
                 $tbodyArray[] = $value['hsCode'];
                 $tbodyArray[] = $value['exportRebateRate'];
                 $tbodyArray[] = $value['importMFNRates'];
                 $tbodyArray[] = $value['generalRate'];
                 $tbodyArray[] = $value['RegulatoryConditions'];
                 $excel->addRow($tbodyArray);
             }
             $excel->finalize();
             exit;
         } elseif ($isOrNot == 2) {
             //没记录的SPU
             $fileName = "noExsitspuHscodeTaxExcel_" . date('Y-m-d_H:i') . ".xls";
             $excel = new ExportDataExcel('browser', $fileName);
             $excel->initialize();
             $tableHeader = array('SPU', '描述', '类别');
             $excel->addRow($tableHeader);
             $tName = 'pc_spu_tax_hscode';
             $select = 'spu';
             if ($type == 1) {
                 //1.中文品名/材质 2.海关编码 3.英文品名/材质
                 $where = "WHERE customsName<>'' and materialCN<>''";
             } elseif ($type == 2) {
                 $where = "WHERE hsCode<>''";
             } elseif ($type == 3) {
                 $where = "WHERE customsNameEN<>'' and materialEN<>''";
             } elseif ($type == 4) {
                 $where = "WHERE customsName<>''";
             }
             $spuList = OmAvailableModel::getTNameList($tName, $select, $where);
             $existSpuArr = array();
             foreach ($spuList as $value) {
                 $existSpuArr[] = "'" . $value['spu'] . "'";
             }
             $existSpuStr = implode(',', $existSpuArr);
             $tName = 'pc_spu_archive';
             $select = 'spu,spuName,categoryPath';
             $where = "WHERE is_delete=0 AND auditStatus=2 ";
             if (!empty($existSpuStr)) {
                 $where .= "AND spu not in({$existSpuStr})";
             }
             $spuArchiveList = OmAvailableModel::getTNameList($tName, $select, $where);
             $totalRows = array();
             foreach ($spuArchiveList as $value) {
                 $tbodyArray = array();
                 $tbodyArray[] = $value['spu'];
                 $tbodyArray[] = $value['spuName'];
                 $tbodyArray[] = getAllCateNameByPath($value['categoryPath']);
                 $excel->addRow($tbodyArray);
             }
             $excel->finalize();
             exit;
         } else {
             echo '参数有误!';
             exit;
         }
     } catch (Exception $e) {
         $errorMsg = $e->getMessage();
         error_log(date('Y-m-d_H:i') . "—— {$errorMsg} \r\n", 3, WEB_PATH . "log/spuHsCodeOutPut.txt");
     }
 }