function act_checkSubmitWebMaker() { $spu = $_POST['spu']; $isSingSpu = $_POST['isSingSpu']; $webMakerId = $_POST['webMakerId']; if ($isSingSpu == 2) { //虚拟料号 self::$errCode = '200'; self::$errMsg = "成功"; return true; } if (intval($webMakerId) <= 0 || isAccessAll('autoCreateSpu', 'isCanUpdateWebMakerPower')) { self::$errCode = '200'; self::$errMsg = "成功"; return true; } $tName = 'pc_spu_web_maker'; $select = 'webMakerId'; $where = "WHERE is_delete=0 and spu='{$spu}' order by id desc"; $spuWebMakerList = OmAvailableModel::getTNameList($tName, $select, $where); if ($spuWebMakerList[0]['webMakerId'] == $webMakerId) { self::$errCode = '200'; self::$errMsg = "成功"; return true; } /* 限制暂时不用 $platformIdArr = array(1,2,11);//其中一个平台必须要有对应销售人员记录 $platformIdStr = implode(',', $platformIdArr); $tName = 'pc_spu_saler_single'; $where = "WHERE is_delete=0 AND spu='$spu' AND platformId in($platformIdStr)"; $singleSalerInfoCount = OmAvailableModel::getTNameCount($tName, $where); if(!$singleSalerInfoCount){ self :: $errCode = '400'; self :: $errMsg = "ebay/aliexpress/amazon 平台中至少要存在一个销售人员记录"; return false; } **/ $tName = 'pc_spu_web_maker'; $select = 'isTake,isAgree'; $where = "WHERE is_delete=0 and spu='{$spu}' and webMakerId='{$webMakerId}' order by id desc"; $webMakerList = OmAvailableModel::getTNameList($tName, $select, $where); if ($webMakerList[0]['isTake'] != 0) { self::$errCode = '200'; self::$errMsg = "成功"; return true; } $appointedCountToWebMaker = getAppointSpuCountByWebMakerId($webMakerId); //已经指派给产品制作人的数量 $countPE = getPECountByPEId($webMakerId); //该产品制作人最多能被指派的数量 if ($appointedCountToWebMaker < $countPE) { self::$errCode = '200'; self::$errMsg = "成功"; return true; } else { self::$errCode = '404'; self::$errMsg = "该产品制作人数量已达极限,请重新选择产品制作人"; return false; } }
public function view_getProductsCombineSpuCompleteList() { $combineSpu = $_GET['combineSpu'] ? post_check(trim($_GET['combineSpu'])) : ''; $userId = $_SESSION['userId']; $tName = 'pc_spu_web_maker a,(select spu,max(id) as id from pc_spu_web_maker group by spu) b'; $select = 'a.*'; $where = 'where a.is_delete=0 AND a.isSingSpu=2 AND a.isTake=1 AND a.isComplete=1 AND a.spu=b.spu and a.id=b.id '; if (!isAccessAll('products', 'getAllCombineSpuListPermission')) { $where .= "AND a.webMakerId='{$userId}' "; } if (!empty($combineSpu)) { $skuArr = array_filter(explode(',', $combineSpu)); $countSkuArr = count($skuArr); for ($i = 0; $i < $countSkuArr; $i++) { if (preg_match("/^[A-Z0-9]+\$/", $skuArr[$i])) { if ($i == 0) { $where .= " AND (a.spu like'{$skuArr[$i]}%' "; } else { $where .= " OR a.spu like'{$skuArr[$i]}%'"; } if ($i == $countSkuArr - 1) { $where .= ") "; } } } } $total = OmAvailableModel::getTNameCount($tName, $where); $num = 50; //每页显示的个数 $page = new Page($total, $num, '', 'CN'); $where .= "order by a.completeTime desc " . $page->limit; $productsComfirmList = OmAvailableModel::getTNameList($tName, $select, $where); if (!empty($productsComfirmList)) { $countProComList = count($productsComfirmList); for ($i = 0; $i < $countProComList; $i++) { $tName = 'pc_auto_create_spu'; $select = 'purchaseId'; $where = "WHERE is_delete=0 AND spu='{$productsComfirmList[$i]['spu']}'"; $autoSpuList = OmAvailableModel::getTNameList($tName, $select, $where); if (!empty($autoSpuList)) { $productsComfirmList[$i]['purchaseId'] = $autoSpuList[0]['purchaseId']; } } } if (!empty($_GET['page'])) { if (intval($_GET['page']) <= 1 || intval($_GET['page']) > ceil($total / $num)) { $n = 1; } else { $n = (intval($_GET['page']) - 1) * $num + 1; } } else { $n = 1; } if ($total > $num) { //输出分页显示 $show_page = $page->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $show_page = $page->fpage(array(0, 2, 3)); } $navlist = array(array('url' => 'index.php?mod=products&act=getProductsComfirmList', 'title' => '产品制作'), array('url' => 'index.php?mod=products&act=getProductsCombineSpuCompleteList', 'title' => '3.虚拟SPU完成')); $this->smarty->assign('navlist', $navlist); $this->smarty->assign('onevar', 5); $this->smarty->assign('twovar', 515); $this->smarty->assign('show_page', $show_page); $this->smarty->assign('title', '3.虚拟SPU完成'); $this->smarty->assign('productsCombineSpuList', empty($productsComfirmList) ? array() : $productsComfirmList); $this->smarty->display("productsCombineSpuCompleteList.htm"); }
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; } }